Skip to content

Commit

Permalink
Time: 6 ms (71.31%), Space: 45.9 MB (16.45%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
avnisinngh committed Dec 4, 2024
1 parent 3207a48 commit 374bf3a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public boolean canMakeSubsequence(String source, String target) {
int targetIdx = 0, targetLen = target.length();

for (char currChar : source.toCharArray()) {
if (targetIdx < targetLen && (target.charAt(targetIdx) - currChar + 26) % 26 <= 1) {
targetIdx++;
}
}
return targetIdx == targetLen;
}
}

0 comments on commit 374bf3a

Please sign in to comment.