Home
Gaurav's GitHub Page
Cancel

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...

One Edit Distance

PROBLEM DESCRIPTION Given two strings s and t, return true if they are both one edit distance apart, otherwise return false. A string s is said to be one distance apart from a string t if you can...

Confusing Number

PROBLEM DESCRIPTION A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid. We can rotate digits of a number by 180 degrees to form new digi...