## Design an evacuation plan of San Francisco residents

This challenge has a common sense. In 2006, Kansas was assigned Grade A (highest) on the Emergency Evacuation Report Map compiled by the American Highway Users Union. New Orleans hit by Hurricane Katrina got D. What is the score for San Francisco? F. New York, Chicago, and Los Angeles have also got this score….

## The task of the cashier-developer

This task was given during the interviews at Apple. Imagine you got a job as a cashier in a store. Your boss accidentally found out that you have the development skills, and wanted you to help him create an application.   Input data: A specified amount of money. An array with all available coins’…

## Create a lock class to prevent deadlock

There are several common options to prevent deadlock. One of the most popular is to explicitly declare what lock is required. This way, we will be able to check whether the created lock is a deadlock and if so, we can stop working.   Let’s take a look and sort out the way we…

## Create a method that counts a number

As usual, initially, we try to solve the task bluntly.   /* Count the number ‘2’ between 0 and n */ int numberOf2sInRange(int n) { int count = 0; for (int i = 2; i <= n; i++) { // We can begin with 2 count += numberOf2s(i); } return count; } /* count…

## The Probability of Meeting a Car on a Deserted Highway

The probability of a car on a deserted highway for a 30 minute period is 0.95. What is the probability of its occurrence in 10 minutes?   This question is difficult to answer because the information that we have is not what we would like to have. However, in real life, it is a…