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 …

Read more

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 …

Read more

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 …

Read more

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 …

Read more

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 …

Read more

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 …

Read more

Reverse a linked list

Problem Statement The problem “reverse a linked list” states that we are given the head of the linked list. We have to reverse the linked list by changing the links between them and return the head of the reversed linked list. Example 10->20->30->40->NULL NULL<-10<-20<-30<-40 Explanation We have reversed the linked …

Read more

Translate »