This question is part of NeetCode150 series. Problem Description You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by c...
Noble Integer
Problem Description Given an integer array A, find if an integer p exists in the array such that the number of integers greater than p in the array equals to p. Solution Let’s say we sort the ar...
Container With Most Water
This question is part of NeetCode150 series. Problem Description You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line ar...
Two Sum II - Input Array Is Sorted
This question is part of NeetCode150 series. Problem Description Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up...
Valid Palindrome
This question is part of NeetCode150 series. Problem Description A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric chara...
Sort K-Sorted Array
Problem Description Given an array of n elements, where each element is at most k away from its target position, you need to sort the array optimally. geeksforgeeks Solution The problem mention...
Maximum Profit When Buying a Car
Problem Description Given two arrays, A and B of size N. A[i] represents the time by which you can buy the ith car without paying any money. B[i] represents the profit you can earn by buying the i...
Distribute Candy
Problem Description There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the fo...
Finish Maximum Jobs
Problem Description There are N jobs to be done, but you can do only one job at a time. Given an array A denoting the start time of the jobs and an array B denoting the finish time of the jobs. Yo...
Kth Largest Element in a Stream
Problem Description Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest cla...