Home
Gaurav's GitHub Page
Cancel

Remove Nth Node From End of List

PROBLEM DESCRIPTION Given the head of a linked list, remove the nth node from the end of the list and return its head. leetcode SOLUTION class Solution { public int getListSize(ListNode no...

Reorder List

PROBLEM DESCRIPTION You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln → L1 →...

Design Twitter

Problem Description Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user’s news feed. Impleme...

Task Scheduler

Problem Description Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in ...

K Closest Points to Origin

Problem Description Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance betwee...

Median of Two Sorted Arrays

Problem Description Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). leetc...

Min Cost Matrix Chain Multiplication

Problem Description Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. ...

Matrix Chain Multiplication

Introduction to Matrix Chain Multiplication

Time Based Key-Value Store

Problem Description Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key’s value at a certain timestamp. Impl...

Find Minimum in Rotated Sorted Array

PROBLEM DESCRIPTION Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it w...