How to Convert a Number to Reversed Array of Digits in Java
The challenge
Given a random non-negative number, you have to return the digits of this number within an array in reverse order.
Test cases
import …
Read Article →
345 articles about java development, tools, and best practices
Given a random non-negative number, you have to return the digits of this number within an array in reverse order.
import …
Read Article →
On a 2-dimensional grid, there are 4 types of squares:
1 represents the starting square. There is exactly one starting square.2 …Find the mean (average) of a list of numbers in an array.
To find the mean (average) of a set of numbers add all of the numbers together …
Read Article →BMI stands for Body Mass Index and is a value derived from the mass and height of a person. The BMI is defined as the body mass divided …
On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: …
We need a function that can transform a string into a number. What ways of achieving this do you know?
Note: Don’t worry, all …
Read Article →Given a non-negative integer n, write a function toBinary/ToBinary which returns that number in a binary format.
to_binary(1) /* should …
Read Article →
Exclusive “or” (xor) Logical Operator
In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, …
Write a function that merges two sorted arrays into a single one. The arrays only contain integers. Also, the final outcome must be …
Read Article →Your job is to find the gravitational force between two spherical objects (obj1 , obj2).
arr_val (value array), …You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number …
Read Article →Given a binary tree, each node has value `` or 1. Each root-to-leaf path represents a binary number starting with the most significant …
Let’s play Rock Paper Scissors! You have to return which player won! In case of a draw return Draw!.
It’s the academic year’s end, fateful moment of your school report. The averages must be calculated. All the students come …
Read Article →Write a function that converts an input string contains a hex value, and return a decimal.
import org.junit.Test;
import …
Read Article →
For a given string s find the character c (or C) with longest consecutive repetition and return:
Object[]{c, l};
where l (or L) is the …
In cryptanalysis, words patterns can be a useful tool in cracking simple ciphers.
A word pattern is a description of the patterns of …
Read Article →Assume "#" is like a backspace in string. This means that string "a#bc#d" actually is "bd"
Your task is to …
Read Article →Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to …
Read Article →Complete the solution so that the function will break up camel casing, using a space between words.
Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then …
Read Article →Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a “Double Cola” drink vending machine; there are no other …
Read Article →Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS)
HH = …Your task is to create a function that turns a string into a Mexican Wave. You will be passed a string and you must return that …
Read Article →