Program to Search in Row-wise and Column-wise Sorted Matrix

Program to search in a row-wise column-wise sorted matrix i.e. printing the location of an element(if it exists) in a row and column-wise sorted matrix.

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

Find Peak Element in Array | Leetcode Problem #162

A peak element is defined as an element that is strictly greater than its neighbor. In this question, you’ll be provided with an array in which you have to find peak element and return its index. In case the array contains multiple peak elements, return the index of any one of the peak elements. You … Read more

Program to Find Square Root of an Integer Using Binary Search

This article will discuss how to find the square root of an integer efficiently using Binary Search. If the number is a perfect square, the program should return the square root, else return the floor of the square root of the number. Before that we first discuss the naive approach to find the square root … Read more

Program to Count Occurrence in a Sorted Array (From Naive to an Efficient Approach)

In this question, you’ll have to find the frequency of a given number(k) in a sorted array (nums[ ]). Below we have provided some of the examples so that you can have a better understanding of how to count occurrence in a sorted array. Naive Solution(Using Linear Search) In this approach, we use a linear … 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

Program to Find all Factors of a Number

In this article we will discuss three methods to Find All the Factors of a given Number. The codes provided will be in Python, but same logic can be used to implement in any other language as well. Iterative Program to Find All Factors of a Number This method uses modulus operation(%) to Find All … Read more

Introduction to Recursion

So first, what is a recursion? Well it’s anything that includes itself in its definition. When you yell your name loud at an edge of a valley and hear it echoing, that’s a physical world example of recursion. While programming, we may sometimes write some function that call other ones. But if we include the … Read more