[HackerRank Solutions] [Java] Introduction – Java Loops

Problem Statement In this problem you will test your knowledge of Java loops. Given three integers a, b, and n, output the following series: Input Format The first line will contain the number of testcases t. Each of the next t lines will have three integers, a, b, and n. Constraints: Output Format Print the […]

Read More

[HackerRank Solutions] [Java] Introduction – Java Stdin and Stdout 2

Problem Statement Most of the problems on HackerRank require reading input from stdin (standard input) and writing output to stdout (standard output). One way to read from stdin is by using the Scanner class and specifying the InputStream as System.in. Alternatively, you can use the BufferedReader class. Lines of output can be written to stdout […]

Read More

[HackerRank Solutions] [Java] Introduction – Java If-Else

Problem Statement Using “if-else” you can perform decision making in Java. See the flowchart below (taken from wikipedia): This problem will test your knowledge on “if-else” statements. Given an integer N as input, check the following: If N is odd, print “Weird”. If N is even and, in between the range of 2 and 5(inclusive), […]

Read More

[HackerRank Solutions] [Java] Introduction – Java Stdin and Stdout 1

Problem Statement In most of the HackerRank challenges, you need to read input from stdin (standard input) and write your output in stdout (standard output). One way to take input from stdin is to use the Scanner class and read in from System.in. You can write your output to stdout by simply using the System.out.println(String) […]

Read More

[HackerRank Solutions] [Java] Introduction – Welcome to Java!

Problem Statement Welcome to the world of Java! Just print “Hello World.” and “Hello Java.” in two separate lines to complete this challenge. The code stub in the editor already creates the main function and solution class. All you have to do is copy and paste the following lines inside the main function.

Sample […]

Read More