bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 925. Long Pressed Name

925. Long Pressed Name

Leetcode Solutions

Two Pointers Approach

  1. Initialize two pointers i and j to 0 for name and typed respectively.
  2. Loop while j is less than the length of typed: a. If i is less than the length of name and name[i] equals typed[j], increment both i and j. b. Else if j is greater than 0 and typed[j] equals typed[j-1], increment j only. c. Else, return false.
  3. After the loop, if i equals the length of name, return true. Otherwise, return false.
UML Thumbnail

Character Group Counting

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...