Home
Gaurav's GitHub Page
Cancel

Minimum Path Sum

PROBLEM DESCRIPTION Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move e...

Furthest Point From Origin

Problem Description You are given a string moves of length n consisting only of characters ‘L’, ‘R’, and ‘_’. The string represents your movement on a number line starting from the origin 0. In t...

Maximum Sum Circular Subarray

PROBLEM DESCRIPTION Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums. A circular array means the end of the array connects to the b...

Find K Pairs with Smallest Sums

PROBLEM DESCRIPTION You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and an integer k. Define a pair (u, v) which consists of one element from the first array and on...

Sort List

PROBLEM DESCRIPTION Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. leetcode SOLUTION First we get the center of...

Convert Sorted Array to Binary Search Tree

PROBLEM DESCRIPTION Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. leetcode SOLUTION We can solve this recursiv...

N-Queens II

Problem Description The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solu...

Combinations

Problem Description Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n]. You may return the answer in any order. Example: Input: n = 4, k = 2 O...

Find First and Last Position of Element in Sorted Array

Problem Description Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, ...

Find Peak Element

Problem Description A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains...