Bird
0
0
DSA Cprogramming~10 mins

Valid Palindrome Two Pointer in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the left pointer at the start of the string.

DSA C
int left = [1];
Drag options to blanks, or click blank then click option'
A0
B1
Cstrlen(s)
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Starting left pointer at 1 skips the first character.
Using strlen(s) causes out-of-bounds access.
2fill in blank
medium

Complete the code to initialize the right pointer at the end of the string.

DSA C
int right = [1] - 1;
Drag options to blanks, or click blank then click option'
A0
Bstrlen(s)
C1
Dsizeof(s)
Attempts:
3 left
💡 Hint
Common Mistakes
Using sizeof(s) returns size of pointer, not string length.
Setting right to 0 starts at the beginning, not the end.
3fill in blank
hard

Fix the error in the while loop condition to continue while left is less than right.

DSA C
while ([1] < right) {
Drag options to blanks, or click blank then click option'
Aright - 1
Bright
Cleft + 1
Dleft
Attempts:
3 left
💡 Hint
Common Mistakes
Using right < right causes no iterations.
Using left + 1 < right is incorrect syntax.
4fill in blank
hard

Fill both blanks to skip non-alphanumeric characters from the left and right pointers.

DSA C
while (left < right && !isalnum(s[[1]])) left++;
while (left < right && !isalnum(s[[2]])) right--;
Drag options to blanks, or click blank then click option'
Aleft
Bright
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed indices like 0 or 1 ignores pointer positions.
Mixing left and right in wrong places causes logic errors.
5fill in blank
hard

Fill all three blanks to compare characters ignoring case and move pointers accordingly.

DSA C
if (tolower(s[[1]]) != tolower(s[[2]])) {
    return false;
}
[3];
[4];
Drag options to blanks, or click blank then click option'
Aleft
Bright
Cleft++
Dright--
Attempts:
3 left
💡 Hint
Common Mistakes
Not using tolower() causes case-sensitive mismatches.
Forgetting to move pointers causes infinite loops.