Home
Gaurav's GitHub Page
Cancel

Count Inversions (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array of integers. Find the Inversion Count in the array. Two array elements arr[i] and arr[j] form an inversion if arr[i] > arr[j] and i < j. Inversion Count: ...

Minimize the Heights II (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array arr[] denoting heights of N towers and a positive integer K. For each tower, you must perform exactly one of the following operations exactly once. Increase...

Merge Strings Alternately

Problem Description You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the addit...

Design Bounded Blocking Queue

Problem Description Implement a thread-safe bounded blocking queue that has the following methods: BoundedBlockingQueue(int capacity) The constructor initializes the queue with a maximum capac...

Minimum Number of Keypresses

Problem Description You have a keypad with 9 buttons, numbered from 1 to 9, each mapped to lowercase English letters. You can choose which characters each button is matched to as long as: All ...

Minimum Adjacent Swaps to Make a Valid Array

Problem Description You are given a 0-indexed integer array nums. Swaps of adjacent elements are able to be performed on nums. A valid array meets the following conditions: The largest eleme...

Next Greater Node In Linked List

Problem Description You are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find the value of the first n...

Minimum Number of Food Buckets to Feed the Hamsters

Problem Description You are given a 0-indexed string hamsters where hamsters[i] is either: ‘H’ indicating that there is a hamster at index i, or ’.’ indicating that index i is empty. You w...

Unique rows in boolean matrix (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a binary matrix your task is to find all unique rows of the given matrix in the order of their appearance in the matrix. geeksforgeeks SOLUTION For each row, we conver...

First non-repeating character in a stream (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an input stream A of n characters consisting only of lower case alphabets. While reading characters from the stream, you have to tell which character has appeared only on...