diff --git a/STRING PRBLEMS/Make String a Subsequence Using Cyclic Increments.java b/STRING PRBLEMS/Make String a Subsequence Using Cyclic Increments.java new file mode 100644 index 00000000..d15b2d75 --- /dev/null +++ b/STRING PRBLEMS/Make String a Subsequence Using Cyclic Increments.java @@ -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; + } +} \ No newline at end of file