Home
Gaurav's GitHub Page
Cancel

Array Subset of another array (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two arrays: a1[0..n-1] of size n and a2[0..m-1] of size m, where both arrays may contain duplicate elements. The task is to determine whether array a2 is a subset of arra...

Sort an array of 0s, 1s and 2s

PROBLEM DESCRIPTION Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order. geeksforgeeks SOLUTION This is a very interesting question and the optimal soluti...

Pascal's Triangle

PROBLEM DESCRIPTION Given an integer numRows, return the first numRows of Pascal’s triangle. In Pascal’s triangle, each number is the sum of the two numbers directly above it. leetcode SOLUTION ...

Max Consecutive Ones III

PROBLEM DESCRIPTION Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s. SOLUTION class Solution { public int...

Validate Binary Search Tree

PROBLEM DESCRIPTION Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes...

Vowel and Consonant Substrings! (InterviewBit)

PROBLEM DESCRIPTION Given a string A consisting of lowercase characters. You have to find the number of substrings in A which starts with vowel and end with consonants or vice-versa. Return the ...

Remove Consecutive Characters (InterviewBit)

PROBLEM DESCRIPTION Given a string A and integer B, remove all consecutive same characters that have length exactly B. NOTE : All the consecutive same characters that have length exactly B will b...

Implement StrStr (InterviewBit)

PROBLEM DESCRIPTION Implement strStr(). strstr - locate a substring ( needle ) in a string ( haystack ). Try not to use standard library string functions for this question. Returns the index of...

Divide Integers (InterviewBit)

PROBLEM DESCRIPTION Divide two integers A and B, without using multiplication, division, and mod operator. Return the floor of the result of the division.Also, consider if there can be overflow c...

Bulls and Cows (InterviewBit)

PROBLEM DESCRIPTION You are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you p...