[Programming Problem] Print FooBar Alternately

Suppose you are given the following code: class FooBar { public void foo() { for (int i = 0; i < n; i++) {...

[Programming Problem] The Dining Philosophers

[Problem Link] Solution here is to add some `ordering` on the resources (i.e. forks) requested by the processes (i.e. the philosophers). Identify the resource...

[Programming Problem] Surrounded Regions

Given an m x n matrix board containing ‘X’ and ‘O’, capture all regions that are 4-directionally surrounded by ‘X’. A region is captured...

[Programming Problem] K Closest Points to Origin

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...

[Programming Problem] Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of...

[Programming Problem] Verifying an Alien Dictionary

In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some...

[Programming Problem] Design Tic-Tac-Toe

Assume the following rules are for the tic-tac-toe game on an n x n board between two players: – A move is guaranteed to...

[Programming Problem] House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint...

[Programming Problem] Paint Fence

You are painting a fence of n posts with k different colors. You must paint the posts following these rules: Every post must be...

[Programming Problem] Time Based Key-Value Store

Create a timebased key-value store class TimeMap, that supports two operations. set(string key, string value, int timestamp) Stores the key and value, along with...