Identifying two pointer subproblem


Some problems may consist of smaller subproblems that can be solved using the two-pointer technique. Solving these subproblems may either partially or fully solve the original problem. These are usually medium or hard problems, as breaking down a problem into subproblems may not be obvious and may require some critical observation. Sometimes, the subproblems themselves may not be solvable by directly applying the two-pointer technique and may require further reduction to a two-pointer pattern problem.

Asking yourself the following questions will help you determine whether a problem is a two-pointer subproblem pattern problem or not.

Ask yourself questions:

Q1. Can the problem or solution be broken down into smaller subproblems?
Q2. Can any subproblem be solved using the two-pointer technique?

Liking the course? Check our discounted plans to continue learning.