葉林
Linked with GitHub
# LeetCode - 0925. Long Pressed Name ### 題目網址:https://leetcode.com/problems/long-pressed-name/ ###### tags: `LeetCode` `Easy` `字串` ```cpp= /* -LeetCode format- Problem: 925. Long Pressed Name Difficulty: Easy by Inversionpeter */ class Solution { public: bool isLongPressedName(string name, string typed) { if (name[0] != typed[0]) return false; int first = 1, second = 1; while (first != name.size()) { if (second == typed.size() || name[first] != typed[second]) { while (second != typed.size() && typed[second - 1] == typed[second]) ++second; if (second == typed.size() || name[first] != typed[second]) return false; } ++first; ++second; } while (second != typed.size() && typed[second - 1] == typed[second]) ++second; return second == typed.size(); } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up