Two Pointer Approach: An Efficient Technique

In this article we will discuss a linear and constant space technique to solve the programming questions. Two pointer Approach is an efficient technique to solve the problem with optimized time and space complexity. Two Pointer Approach Algorithm is mostly used for solving the array problems, where pointers are actually array indexes. Whenever the solution … Read more

Median of Two Sorted Arrays | Leetcode Problem #4

In this question, given two sorted arrays nums1 and nums2 of size m and n respectively, you have to return the median of two sorted arrays Goal: The overall run time complexity should be O(log(m+n)) Naive Solution to Find Median of Two Sorted Arrays In this solution, we create a vector and then insert all … Read more

Find Repeating Element in Array| Leetcode #287

This article will discuss various approaches to find the element repeating more than once in an array, from naive to most efficient. Problem statement: Given an array of size n where each element is in the range [1,n-1], exactly one element repeats any no. of times in the array. Find that repeating element. Input: arr = … Read more

Maximum Sum Circular Subarray | Leetcode #918

Maximum Sum Circular Subarray this problem is variation of Maximum Sum Subarray question where we implemented the Kadane’s Algorithm. Check out our previous blog post on Kadane’s Algorithm here. Link to the current question https://leetcode.com/problems/maximum-sum-circular-subarray/ Let us consider an array {2, 1, -5, 4, -3, 1, -3, 4, 1}. So according to the problem the … Read more

Window Sliding Technique – An Efficient Technique

The window sliding technique if helpful when you have to reduce the time complexity from O(N2) to O(N) by converting nested loop into a single loop in problems that includes linear sequences, like arrays. A window is a contiguous sequence of elements in an array and as the name suggests in the window sliding technique, … Read more

Kadane’s Algorithm – Maximum Sum Subarray

The given task in this problem is that we have to find the series of contiguous elements with the maximum sum in any given array. You can find the problem here which is based on this algorithm. Before jumping to the Kadane’s algorithm, we will look the naive solution of this problem, and then we … Read more