Implement a rate limiter

shouldAllowRequest() that returns true if the incoming requests have arrived at a rate less than or equal to specified rate, false otherwise. 1. What if you don’t have to worry about bursts? 2. What if you want to handle burst?

Boolean String Value

Given a string consisting of only 0, 1, A, B, C where A = AND B = OR C = XOR Calculate the value of the string assuming no order of precedence and evaluation is done from left to right. Examples: Input : 1A0B1 Output : 1 1 AND 0 OR 1 = 1 Input… Read More »

Prime number problem

You need to a number of floors in a building. There are 68 floors (numbered 1 to 64). Conditions: 1. Can’t buy floors which numbers are prime. 2. Cannot buy floors which number contains a prime digit. 3. Can’t buy floor number 1. 4. Distance between all purchased floors must be different (i.e. you can’t… Read More »

Missing country code

Missing Country Code Imagine you get a data set from a client that contains addresses from 150 countries all around the world and your task is to verify them, the data is stored in 4 fields – Address Line 1, Address Line 2, City, ZIP code. What you also have available is address verification solution… Read More »

Prime number problem

A man has to buy 7 floors in a building. Numbered floor 1 to 68. Conditions: 1. He cannot buy floors with prime number. 2. He cannot buy floor number containing prime digit. 3. Floor number 1 is reserved for services. 4. Difference between all remaining floors shoud be different. 5. Difference between all remaing… Read More »

100 doors to be painted

You have 100 doors to be painted and 2 painters. 1 starts at one end and paints every other door. The other painter starts at the other end and paints every 3rd door. What door number will they meet at?