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

Task on list copying

Task on list copying

115 tasks from IT interviews

Books for Java beginners

How did I extensively simplify the interaction with Raspberry Pi?

Artificial intelligence is not what it seems.

Ada Lovelace

Want to know everything. Solidity

Books about programming: how and what to read

11 applications to learn programming on mobile devices

Top 10 TV series for IT geeks

Software development methodologies

Ada Lovelace – the first developer in the world

9 reasons to change Windows 10 for Linux

25 most popular myths about programming and developers

Top 10 films and TV series on IT topics

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;…