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 C++
int left = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Starting left pointer at 1 skips the first character.
Using s.size() - 1 sets pointer at the end, not start.
✗ 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 C++
int right = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Using s.size() causes out-of-bounds error.
Starting at 0 sets pointer at the start, not the end.
✗ Incorrect
The right pointer should start at the last character index, which is size minus one.
3fill in blank
hardFix the error in the while loop condition to continue while left is less than right.
DSA C++
while ([1] < right) {
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'right < right' makes the condition always false, preventing the loop from executing.
Using 's.size() < right' is incorrect comparison.
✗ Incorrect
The loop should run while the left pointer is less than the right pointer.
4fill in blank
hardFill both blanks to skip non-alphanumeric characters from left and right pointers.
DSA C++
while (left < right && !isalnum(s[[1]])) left++; while (left < right && !isalnum(s[[2]])) right--;
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed indices like 0 or s.size() - 1 causes wrong skipping.
Mixing left and right pointers in conditions.
✗ Incorrect
We check characters at left and right pointers to skip non-alphanumeric characters.
5fill in blank
hardFill all three blanks to compare characters ignoring case and move pointers accordingly.
DSA C++
if (tolower(s[[1]]) != tolower(s[[2]])) return false; left[3]; right--;
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--' on left pointer moves it backward incorrectly.
Comparing characters without tolower causes case mismatch.
✗ Incorrect
Compare characters at left and right pointers ignoring case, then move left pointer forward and right pointer backward.
