How does the optimized two-pointer approach save space?

Practice this question from Valid Palindrome - Two pointers Pattern Practice Quiz, with options and an explanation.

Question

How does the optimized two-pointer approach save space?

Option A — Correct answer

It avoids creating a cleaned copy

Option B

It sorts in place

Option C

It stores every prefix

Option D

It uses recursion depth

Explanation

It skips invalid characters while comparing from both ends without creating a cleaned copy.

Valid Palindrome - Two pointers Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker