Leap

Problems related to two pointers

· Sai Kiran

To get the linear time complexity while solving some problems on arrays or linked lists, we can use two-pointers technique.

Problems

  • Given an array find if there exists two numbers that sum to given K.
    • Sort the array and use two pointers from both ends.
  • Remove duplicates from a sorted array/linked list.
  • Transform the given array: Even numbers should be in the first half and odd number will be the sencond half.
  • Pivoting of linked list (EPI Python)

To read

  • Rain water harvesting and its relation to NGE problem