We define the following: A subarray of an -element array is an array composed from a contiguous block of the original array's elements. For example, if , then the subarrays are , , , , , and . Something like would not…
You are given a 2D array. An hourglass in an array is a portion shaped like this: For example, if we create an hourglass using the number 1 within an array full of zeros, it may look like this: Actually, there are many…
An array is a simple data structure used to store a collection of data in a contiguous block of memory. Each element in the collection is accessed using an index, and the elements are easy to find because they're stored…
In this problem, you have to add and multiply huge numbers! These numbers are so big that you can't contain them in any ordinary data types like a long integer. Use the power of Java's BigInteger class and solve this…
A prime number is a natural number greater than whose only positive divisors are and itself. For example, the first six prime numbers are , , , , , and . Given a large integer, , use the Java BigInteger class'…
You are updating the username policy on your company's internal networking platform. According to the policy, a username is considered valid if all the following constraints are satisfied: The username consists of to…
Using Regex, we can easily match or search for patterns in a text. Before searching for a pattern, we have to specify one using some well-defined syntax. In this problem, you are given a pattern. You have to check…
Given a string, , matching the regular expression [A-Za-z !,?._'@]+, split the string into tokens. We define a token to be one or more consecutive English alphabetic letters. Then, print the number of tokens, followed…
Two strings, and , are called anagrams if they contain all the same characters in the same frequencies. For example, the anagrams of CAT are CAT, ACT, TAC, TCA, ATC, and CTA. Complete the function in the editor. If and…
"A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable." — Wikipedia: String (computer science) This exercise is to test your understanding of Java Strings. A…
The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the…
You are given an integer , you have to convert it into a string. Please complete the partially completed code in the editor. If your code successfully converts into a string the code will print "Good job". Otherwise it…
"In computing, End Of File (commonly abbreviated EOF) is a condition in a computer operating system where no more data can be read from a data source." — (Wikipedia: End-of-file) The challenge here is to read lines of…
Java has 8 primitive data types; char, boolean, byte, short, int, long, float, and double. For this exercise, we'll work with the primitives used to hold integer values (byte, short, int, and long): A byte is an 8-bit…
We use the integers , , and to create the following series: You are given queries in the form of , , and . For each query, print the series corresponding to the given , , and values as a single line of space-separated…
Objective In this challenge, we're going to use loops to help us do some simple math. Task Given an integer, , print its first multiples. Each multiple (where ) should be printed on a new line in the form: N x i =…
Java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf. To get you started, a portion of the solution is…
In this challenge, you must read an integer, a double, and a String from stdin, then print the values according to the instructions in the Output Format section below. To make the problem a little easier, a portion of…
In this challenge, we test your knowledge of using if-else conditional statements to automate decision-making processes. An if-else statement has the following logical flow: Source: Wikipedia Task Given an integer…
Most HackerRank challenges require you to read input from stdin (standard input) and write output to stdout (standard output). One popular way to read input from stdin is by using the Scanner class and specifying the…