Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the left pointer at the start of the string.
DSA Java
int left = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Starting left pointer at 1 skips the first character.
Using s.length() causes index out of bounds.
Using -1 is invalid index.
✗ Incorrect
The left pointer should start at index 0 to begin checking from the start of the string.
2fill in blank
mediumComplete the code to initialize the right pointer at the end of the string.
DSA Java
int right = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Using s.length() causes index out of bounds.
Using 0 starts at the beginning, not the end.
Using -1 is invalid index.
✗ Incorrect
The right pointer should start at the last character index, which is length - 1.
3fill in blank
hardFix the error in the while loop condition to continue while left is less than right.
DSA Java
while ([1] < right) {
Attempts:
3 left
💡 Hint
Common Mistakes
Using right < right is always false.
Using s.length() < right is incorrect comparison.
Using 0 < right ignores left pointer.
✗ Incorrect
The loop should run while left pointer is less than right pointer to compare characters.
4fill in blank
hardFill both blanks to skip non-alphanumeric characters from left and right pointers.
DSA Java
while (left < right && !Character.[1](s.charAt(left))) left++; while (left < right && !Character.[2](s.charAt(right))) right--;
Attempts:
3 left
💡 Hint
Common Mistakes
Using isWhitespace skips spaces only, not all non-alphanumeric.
Using isDigit skips only digits, missing letters.
Using isLetter skips only letters, missing digits.
✗ Incorrect
We skip characters that are not letters or digits on both sides.
5fill in blank
hardFill all three blanks to compare characters ignoring case and move pointers.
DSA Java
if (Character.[1](s.charAt(left)) != Character.[2](s.charAt(right))) { return false; } left[3]; right--;
Attempts:
3 left
💡 Hint
Common Mistakes
Using different case conversions on left and right causes mismatch.
Not moving pointers causes infinite loop.
Using decrement on left pointer is wrong direction.
✗ Incorrect
Convert both characters to lowercase to compare ignoring case, then move left pointer forward.
