### Meeting Rooms

Given an array of intervals representing N meetings, find out if a person can attend all the meetings. Input: [[6,7],[2,4],[8,12]] Output: true Explanation: None of the meetings overlap with each other. Input: [[1,4],[2,5],[7,9]] Output: false Explanation: Meetings [1,4] and [2,5] overlap with each other. This problem is commonly asked nowadays ...

### Largest sum of non-adjacent numbers

Given an array of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative.For example, Input: [2, 4, 6, 2, 5] Output: 13 Explanation: Since we pick 2, 6, and 5. Input: [5, 1, 1, 5] Output: 10 Explanation: Since we pick ...

### Is subsequence

Given a string s and a string t, check if s is subsequence of t. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, ...

### Rotten oranges problem

Rotten oranges problem goes like: In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the ...

### Trapping rain water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rain. For example, Input: [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Basic thought We know water stays at the highest level it is able to, and it always maintains the ...

### Longest subarray with sum at most k

Given an array of integers A[], find the length of the longest subarray with the sum at most k where k is an integer. For example: Input: A[] = [10, 5, 2, 7, 1, 9], k = 15 Output: 4 Explanation longest subarray with sum at most K is [ ...

### Remove duplicate characters

Given a string, remove consecutive duplicate characters from the string. For example: Input: S = "aabccacc" Output: "ba" Input: S = "accacc" Output: "" Solution for this problem is in the idea that we need two pointers, one to read a character and another to write a character. In this ...

### Number of islands

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Input: 11110 11010 11000 ...

### Critical Connections in a Network

There are n servers numbered from 0 to n-1 connected by undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. Any server can reach any other server directly or indirectly through the network. A critical connection is a connection that, if removed, ...

### Maximum area rectangle in a histogram

A histogram is a diagram consisting of rectangles whose area is proportional to the frequency of a variable and whose width is equal to the class interval. Below is an example of a histogram. Given a histogram, whose class interval is 1, find maximum area rectangle in it. Let me ... 