Given an array of size n, find the majority element. The element that appears more than ⌊ n/2 ⌋ times in the array. Note: Input will be a non-empty and unsorted array. Example Solution Approach 1. Sorting On sorting the given array, the element occurring more than [n/2] times will… Read More »Majority Element in an Array – LeetCode
Algorithms, Data Structures, Competitive Coding, and problems from LeetCode with complete Solution Approach, Pseudocode, and Explanation.
Sorting algorithms are cool. But, every time I learn or refer to any algorithm in my head or watch a YouTube video, I can understand and recall how it works but, my brain starts yelling – write the code! write the code! If you are trying to learn or understand… Read More »Sorting Algorithms in C++
Given a matrix of N dimensions, and we need to transpose it. One of the standard problem on matrices. Don’t confuse Transpose with Rotation, the rotation is normally performed on the X-Y axis while in a transpose, the matrix is flipped on its diagonal. Example: Solution Approach This is simple… Read More »Transpose a Matrix
In this post we’ll be solving a simple problem using an Array of Structures. Problem Statement: Read an input of [N] API calls and find their Average, Each call has three timestamps [T1, T2, T3] and we need to give separate average for each. Example Output Explanation, in the above… Read More »Array of Structures – API Problem
I had started the #30DaysofCode📚 challenge while I was revising the basic concepts, data structures, and solving easy problems on LeetCode. I documented this so that it helps both me and others to recall what we have learned. How to use this list📑 First, look at the given questions, if… Read More »#30DaysofCode
In programming, Recursion means a function calling itself. The best use of recursion is when we have a big/complex problem and is solved by breaking down the problem into smaller instances. In this post, we’ll see direct and indirect recursion. Types of Recursion Generally, there are two main types of… Read More »Direct & Indirect Recursion