## Number of Islands LeetCode Solution

Problem Statement The number of Islands LeetCode Solution – “Number of Islands” states that you are given an m x n 2D binary grid which represents a map of ‘1’s (land) and ‘0’s (water), you have to return the number of islands. An island is surrounded by water and is …

## Minimum Absolute Difference Leetcode Solution

The problem Minimum Absolute Difference Leetcode Solution provides us an unsorted array or vector containing some integers. We are required to find out all the pairs that have a difference equal to that of minimum absolute difference. The minimum absolute difference is the minimum value of absolute difference that can …

## Permutations Leetcode Solution

The problem Permutations Leetcode Solution provides a simple sequence of integers and asks us to return a complete vector or array of all the permutations of the given sequence. So, before going into solving the problem. We should be familiar with permutations. So, a permutation is nothing but an arrangement …

## Find the Smallest Divisor given a Threshold Leetcode Solution

This post is on Find the Smallest Divisor given a Threshold Leetcode Solution Problem statement In the problem ” Find the Smallest Divisor Given a Threshold” we are given a nums array and a threshold value. A variable “result” is defined as the sum of all answers when elements in …

## Longest Substring Without Repeating Characters LeetCode Solution

Longest Substring Without Repeating Characters LeetCode Solution – Given a string, we have to find the length of the longest substring without repeating characters. Let’s look into a few examples: Example pwwkew 3 Explanation: Answer is “wke” with length 3 aav 2 Explanation: Answer is “av” with length 2 Approach-1 …

## Design a stack that supports getMin() in O(1) time and O(1) extra space

Design a stack that supports getMin() in O(1) time and O(1) extra space. Thus the special stack data structure must support all the operations of the stack like – void push() int pop() bool isFull() bool isEmpty() in constant time. Add an additional operation getMin() to return the minimum value …

## GCD Of Two Numbers

What is Greatest Common Factor? GCD of two numbers is the largest number that divides both of them. Approach-1 Brute Force Finding all the prime factors of both the numbers, then finding the product of the intersection. Finding the largest number that divides both the numbers. What is it that …

## Rotate Array

Rotate array is a problem in which we have given an array of size N. We have to rotate the array in the right direction. Each element shift by one position right and last element of the array come to the first position. So, we have given a value K …

## Quick Sort

Quick Sort is a sorting algorithm. Given an unsorted array sort it using quick sort algorithm. Example Input: {8, 9, 5, 2, 3, 1, 4} Output: {1, 2, 3, 4, 5, 8, 9} Theory It’s a Divide and Conquer sorting Algorithm. It picks a pivot element in the array, splits …