Home
Gaurav's GitHub Page
Cancel

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

Wiggle Sort

PROBLEM DESCRIPTION Given an integer array nums, reorder it such that nums[0] <= nums[1] >= nums[2] <= nums[3]…. You may assume the input array always has a valid answer. leetcode SOLU...

Maximum Distance in Arrays

PROBLEM DESCRIPTION You are given m arrays, where each array is sorted in ascending order. You can pick up two integers from two different arrays (each array picks one) and calculate the distance....

Best Time to Buy and Sell Stock IV

Problem Description You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k. Find the maximum profit you can achieve. You may complete ...

Best Time to Buy and Sell Stock III

Problem Description You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete at most two transactions. ...

Word Search II

Problem Description Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where ...

Text Justification

PROBLEM DESCRIPTION Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should p...