Home
Gaurav's GitHub Page
Cancel

Missing Ranges

PROBLEM DESCRIPTION You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are within the inclusive range. A number x is considered missing if ...

Candy Crush

PROBLEM DESCRIPTION Given an m x n integer array board representing the grid of candy where board[i][j] represents the type of candy. A value of board[i][j] == 0 represents that the cell is empty....

Sparse Matrix Multiplication

PROBLEM DESCRIPTION Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume that multiplication is always possible. leetcode SOLUTION...

Group Shifted Strings

PROBLEM DESCRIPTION Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters. leetcode SOLUTION We find how many shifts it would take i...

Find K-Length Substrings With No Repeated Characters

PROBLEM DESCRIPTION Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters. leetcode SOLUTION class Solution { public int numKLenSu...

Max Consecutive Ones II

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

Longest Substring with At Most Two Distinct Characters

PROBLEM DESCRIPTION Given a string s, return the length of the longest substring that contains at most two distinct characters. leetcode SOLUTION class Solution { public int lengthOfLonges...

Shortest Way to Form String

PROBLEM DESCRIPTION A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of ...

Longest Arithmetic Subsequence of Given Difference

Problem Description Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjac...

Reverse Words in a String II

PROBLEM DESCRIPTION Given a character array s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by a single space. Your cod...