LeetCode:925.长按键入

LeetCode:925.长按键入

思想:基本程序设计

public boolean isLongPressedName(String name, String typed) {
        if(name.equals(typed)) return true;
        for (int i = 0, j = 0; i < name.length();) {
            try {
                if (name.charAt(i) == typed.charAt(j)) {
                    j++;
                    i++;
                    continue;
                }

                else if (name.charAt(i - 1) == typed.charAt(j)) {
                    j++;
                    continue;
                }
                else {
                    return false;
                }
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

 

posted @ 2019-05-14 23:54 godoforange 阅读(...) 评论(...) 编辑 收藏

相关文章:

  • 2021-06-14
  • 2021-09-02
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-12-19
  • 2021-12-05
猜你喜欢
  • 2021-09-14
  • 2021-07-09
  • 2021-07-14
  • 2021-08-02
  • 2021-07-07
  • 2021-10-19
  • 2021-09-01
相关资源
相似解决方案