leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE |

2825.cpp (381B)


1 class Solution { 2 public: 3 bool canMakeSubsequence(string str1, string str2) { 4 int i = 0, j = 0; 5 6 while (i < size(str1) && j < size(str2)) { 7 if (str1[i] == str2[j] || str1[i] + 1 == str2[j] || (str1[i] == 'z' && str2[j] == 'a')) { 8 i++, j++; 9 } else 10 i++; 11 } 12 13 return j == size(str2); 14 } 15 };