This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
// Given a stream of numbers, return a set of k (fixed) numbers from it uniformly at random. | |
// Also, prove that your solution is actually uniformly random.- https://en.wikipedia.org/wiki/Reservoir_sampling | |
namespace ReservoirSampling | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace MinimumCoins | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace HashMapImplementation | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
int n = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
// Given a sequence of integers and a size k, | |
// print the minimum number for every sliding window of size k | |
namespace SlidingMinimum | |
{ | |
public class Program | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TrafficLights | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var trafficLightController = TrafficLightController.getInstance(); | |
Console.WriteLine("Press Ctrl C to stop"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
// https://codility.com/media/train/3-PrefixSums.pdf | |
namespace MushroomPicker | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
// An array of integers of size n is represented by a forest aka a collection of trees. | |
// The tree is a n-ary tree and has the property that the parent's value is always smaller | |
// than its children | |
// Given these conditions, write a method to delete a number from this array given an index. | |
// This should also re-arrange the forest | |
// Value of each node is an index in the array | |
// Root nodes have the value -1 | |
// Child nodes have the parent as the value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Linq; | |
// Question: | |
// We've taken some strings and chopped them up into pieces at random spots, then we're rearranged them and stuck them back together! | |
// Your goal is to write some code that turns that process backwards. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
// Oh no! Disaster has struck some of ACME's redundant data centers. The administrators have managed to restore backups, but some data sets are still missing from some data centers. Fortunately, every data set can be found at least once in one or more of the data centers. However, before ACME can resume normal operations, it needs to ensure that each data center has a copy of every data set. | |
// | |
// Your goal is to help ACME resume normal operations by writing a program to synchronize data sets between data centers using as few copies as possible. | |
// | |
// | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
// Given a string containing a combination of words and numbers, sort the string | |
// such that the words and numbers maintain their position in the string | |
// Input: car 2 bus 1 | |
// Output: bus 1 car 2 | |
namespace SortWordsAndNumbers |