# Java

## How to Solve Unique Paths III in Java

The challenge On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square.  There is exactly one starting square. 2 represents the ending square. … Read More »How to Solve Unique Paths III in Java

## How to Calculate BMI in Java

The challenge BMI stands for Body Mass Index and is a value derived from the mass and height of a person. The BMI is defined… Read More »How to Calculate BMI in Java

## How to Convert a String to a Number in Java

The challenge We need a function that can transform a string into a number. What ways of achieving this do you know? Note: Don’t worry,… Read More »How to Convert a String to a Number in Java

## How to Convert an Integer to Binary using Java

The challenge Given a non-negative integer n, write a function toBinary/ToBinary which returns that number in a binary format. Test cases The solution in Java Alternative 1: Alternative… Read More »How to Convert an Integer to Binary using Java

## How to create a Logical Operator in Java

Exclusive “or” (xor) Logical Operator In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, etc.) called the “Exclusive Or”. The exclusive or… Read More »How to create a Logical Operator in Java

## Playing the Bulls and Cows Game in Java

The challenge 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… Read More »Playing the Bulls and Cows Game in Java

## Calculate the Sum of Root To Leaf Binary Numbers in Java

The challenge Given a binary tree, each node has value 0 or 1.  Each root-to-leaf path represents a binary number starting with the most significant bit.  For example,… Read More »Calculate the Sum of Root To Leaf Binary Numbers in Java

## How to “Rock Paper Scissors” in Java

The challenge Let’s play Rock Paper Scissors! You have to return which player won! In case of a draw return Draw!. Examples: The rules of the… Read More »How to “Rock Paper Scissors” in Java

## Get the mean of an array in Java

The challenge It’s the academic year’s end, fateful moment of your school report. The averages must be calculated. All the students come to you and… Read More »Get the mean of an array in Java

## How to Convert Hex to Decimal in Java

The challenge Write a function that converts an input string contains a hex value, and return a decimal. Test cases The solution in Java In… Read More »How to Convert Hex to Decimal in Java

## Character with Longest Consecutive Repetition in Java

The challenge For a given string s find the character c (or C) with longest consecutive repetition and return: where l (or L) is the length of the repetition. If there are two… Read More »Character with Longest Consecutive Repetition in Java

## Cryptanalysis Word Patterns in Java

The challenge In cryptanalysis, words patterns can be a useful tool in cracking simple ciphers. A word pattern is a description of the patterns of… Read More »Cryptanalysis Word Patterns in Java

## Backspaces in String Challenge using Java

The challenge Assume “#” is like a backspace in string. This means that string “a#bc#d” actually is “bd” Your task is to process a string with “#” symbols. Examples Test cases The… Read More »Backspaces in String Challenge using Java

## The SongDecoder Dubstep Challenge with Java

The challenge Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided… Read More »The SongDecoder Dubstep Challenge with Java

## Break camelCase Challenge in Java

The challenge Complete the solution so that the function will break up camel casing, using a space between words. Example Test cases The solution in… Read More »Break camelCase Challenge in Java

## The “Split Strings” Challenge using Java

The challenge Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters… Read More »The “Split Strings” Challenge using Java

## Solving the “Double Cola” Challenge using Java

The challenge Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a “Double Cola” drink vending machine; there are no other people in… Read More »Solving the “Double Cola” Challenge using Java

## Convert String to Camel Case using Java

The challenge Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the… Read More »Convert String to Camel Case using Java

## Sort a Java Integer in Descending Order

The challenge Your task is to make a function that can take any non-negative integer as an argument and return it with its digits in… Read More »Sort a Java Integer in Descending Order