No history yet

Final Exam

 

1.What is the primary advantage of the two-pointer technique, especially for problems involving sorted arrays?

 

2.When finding a pair in a sorted array that sums to a target T, you use a left and right pointer. If the sum of the elements at these pointers is less than T, which action should you take?

 

3.The two-pointer technique where pointers move towards each other is often called the 'meet in the middle' or 'converging' pattern. For which of these problems is this pattern most suitable?

 

4.When using two pointers to remove duplicates from a sorted array nums in-place, what is the typical role of each pointer?

 

5.What is the time complexity for merging two sorted arrays of lengths m and n into a new array using the two-pointer technique?

 

6.In the 'Container with Most Water' problem, you are given an array of heights. Two pointers, left and right, form the sides of a container. Why do you always move the pointer corresponding to the shorter height?

 

7.How can the two-pointer technique be adapted to solve the Three-Sum problem (finding triplets that sum to zero) in an array?

 

8.Which of the following problems is LEAST suitable for a standard two-pointer approach?

 

9.The 'Sliding Window' technique can be considered a variation of the two-pointer method.

 

10.To solve the 'Trapping Rainwater' problem, a common two-pointer approach involves tracking the maximum height seen from the left (left_max) and the right (right_max). If height[left] < height[right], you process the left pointer. Why?

 

11.Consider the task of reversing only the letters in a string, leaving other characters (like numbers or symbols) in place. E.g., "a-bC-d" becomes "d-Cb-a". How would you apply two pointers?

All done? Get your grade