Technique utilizing two pointers to efficiently solve problems or traverse data structures.
Problem Statement: Given a string, return the length of the longest substring without repeating characters. Examples Example 1: Input: string s = “cadbzabcd” Output: 5 Explanation: All possible...
Problem Statement: Find the intersection of two sorted arrays. OR in other words, Given 2 sorted arrays, find all the elements which occur in both the arrays. Examples Example 1: Input: A: [1, 2, 3...
Problem Statement: Given an array of length N consisting of only 0s and 1s in random order. Modify the array to segregate 0s on the left and 1s on the right side of the array. Examples Input : N =...
This is one of the approaches which can be used to solve a problem in optimal time. First, we’ll understand every aspect of this approach and would later discuss a very common problem for a bette...
Problem Statement: You are given an array of integers, your task is to move all the zeros in the array to the end of the array and move non-negative integers to the front by maintaining their order...
Problem Statement: Given an integer array sorted in non-decreasing order, remove the duplicates in place such that each unique element appears only once. The relative order of the elements should b...
Problem Statement: Given an array of N integers, your task is to find unique quads that add up to give a target value. In short, you need to return an array of all the unique quadruplets [arr[a],...
Problem Statement: Given a linked list and an integer N, the task is to delete the Nth node from the end of the linked list and print the updated linked list. Examples Input: 5->1->2, N=2 Output: 5...
Problem Statement: Given an array of integers arr[] and an integer target. 1st variant: Return YES if there exist two numbers such that their sum is equal to the target. Otherwise, return NO. 2nd v...