Loading…

Implement an algorithm to print all valid

Given an input file with four billion non-negative integers

You have 20 bottles of pills

Write a function that adds two numbers

A magic index in an array A[1… n-1]

A magic index in an array A[1… n-1]

Implement an algorithm to determine

There’s a staircase

You have to get from point A to point B

Given a list of millions of words, design an algorithm

Design an evacuation plan of San Francisco residents

The task of the cashier-developer

Create a lock class to prevent deadlock

Create a method that counts a number

The Probability of Meeting a Car on a Deserted Highway

Finding the maximum of two numbers

The task of calendar gaps merging

The task of calendar gaps merging

The task of the ball with helium in the car

The task of Apple shares

In the darkroom, you are handed a deck of cards.

How far can you deliver cargo using N trucks?

In what situation you will get less wet getting to the car

You are given three boxes

You are given three boxes

You are given three boxes and you need to define which one contains the prize

A logical task about the height of an egg crash

A logical task on placing the dices on a chessboard

What errors can cause a C application crash

Piece of cheese in the shape of a cube and a knife.

Piece of cheese in the shape of a cube and a knife.

You are given a piece of cheese in the shape of a cube and a knife.

Find errors in the following code block

10 thousand servers in the data centre with remote control.

You manage 10 thousand servers in the data centre with remote control.

You have an analogue clock with a second hand.

How many golf balls will be heard into the school bus?

Implement an algorithm to print all valid

  Our first thought here might be to apply a recursive approach where we build the solution for f(n) by adding pairs of parentheses to f (n-1). That’s certainly a good instinct.   Let’s consider the solution for n = 3: (()()) ((())) ()(()) How might we build this from n = 2? (()) ()()…

Given an input file with four billion non-negative integers

  FOLLOW UP: What if you have only 1 O MB of memory? Assume that all the values are distinct and we now have no more than one billion non-negative integers.   There are a total of 232, or 4 billion, distinct integers possible and 231 non-negative integers. Therefore, we know the input file (assuming…

You have 20 bottles of pills

    Sometimes, tricky constraints can be a clue. This is the case with the constraint that we can only use the scale once.   Because we can only use the scale once, we know something interesting: we must weigh multiple pills at the same time. In fact, we know we must weigh pills from…

Write a function that adds two numbers

    Our first instinct in problems like these should be that we’re going to have to work with bits. Why? Because when you take away the+ sign, what other choice do we have? Plus, that’s how computers do it!   Our next thought should be to deeply understand how addition works. We can walk…

A magic index in an array A[1… n-1]

Immediately, the brute force solution should jump to mind and there’s no shame in mentioning it. We simply iterate through the array, looking for an element which matches this condition.   int magicSlow(int[] array) { for (int i= 0; i < array.length; i++) { if (array[i] == i) { return i; } } return -1;…