Home
Gaurav's GitHub Page
Cancel

Rotate List

PROBLEM DESCRIPTION Given the head of a linked list, rotate the list to the right by k places. leetcode SOLUTION APPROACH 1 class Solution { public ListNode rotateRight(ListNode head, int...

Swap Nodes in Pairs

PROBLEM DESCRIPTION Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list’s nodes (i.e., only nodes themselves...

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