[Geeks for Geeks] Maximum absolute difference between sum of two contiguous sub-arrays

Maximum absolute difference between sum of two contiguous sub-arrays

Given an array of integers, find two non-overlapping contiguous sub-arrays such that the absolute difference between the sum of two sub-arrays is maximum.

Read more
[Geeks for Geeks] Overlapping Intervals

Overlapping Intervals

Given a collection of Intervals, the task is to merge all of the overlapping Intervals.

Read more
[Geeks for Geeks] Min cut Square

Min cut Square

Given two numbers M and N, which represents the length and breadth of a paper, the task is to cut the paper into squares of any size and find the minimum number of squares that can be cut from the paper.

Read more
[Geeks for Geeks] LRU Cache

LRU Cache

Design a data structure that works like a LRU Cache. Here cap denotes the capacity of the cache and Q denotes the number of queries. Query can be of two types:

  1. SET x y : sets the value of the key x with value y
  2. GET x : gets the key of x if present else returns -1.

The LRUCache class has two methods get() and set() which are defined as follows.

  1. get(key) : returns the value of the key if it already exists in the cache otherwise returns -1.
  2. set(key, value) : if the key is already present, update its value. If not present, add the key-value pair to the cache. If the cache reaches its capacity it should invalidate the least recently used item before inserting the new item.
  3. In the constructor of the class the capacity of the cache should be intitialized.
Read more
[Geeks for Geeks] Connect Nodes at Same LevelRead more
[Geeks for Geeks] Word Boggle

Word Boggle

Given a dictionary of distinct words and an M x N board where every cell has one character. Find all possible words from the dictionary that can be formed by a sequence of adjacent characters on the board. We can move to any of 8 adjacent characters

Note: While forming a word we can move to any of the 8 adjacent cells. A cell can be used only once in one word.

Read more
[Geeks for Geeks] Non Repeating Numbers

Non Repeating Numbers

Given an array A containing 2 x N+2 positive numbers, out of which 2 x N numbers exist in pairs whereas the other two number occur exactly once and are distinct. Find the other two numbers.

Read more
[Geeks for Geeks] Find median in a stream

Find median in a stream

Given an input stream of N integers. The task is to insert these numbers into a new stream and find the median of the stream formed by each insertion of X to the new stream.

Read more
[Geeks for Geeks] Maximum Index

Maximum Index

Given an array A[] of N positive integers. The task is to find the maximum of j - i subjected to the constraint of A[i] < A[j] and i < j.

Read more
[LeetCode] Smallest Range Covering Elements from K Lists

632. Smallest Range Covering Elements from K Lists

You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists.

We define the range [a, b] is smaller than range [c, d] if b - a < d - c or a < c if b - a == d - c.

Read more