# Java

## The Deaf Rats of Hamelin Challenge in Java

The challenge The Pied Piper has been enlisted to play his magical tune and coax all the rats out of town. But some of the rats are… Read More »The Deaf Rats of Hamelin Challenge in Java

## How to Find the Next Perfect Square in Java

The challenge You might know some pretty large perfect squares. But what about the NEXT one? Complete the findNextSquare method that finds the next integral perfect square… Read More »How to Find the Next Perfect Square in Java

## How to Solve Two-Sum in Java

The challenge Write a function that takes an array of numbers (integers for the tests) and a target number. It should find two different items… Read More »How to Solve Two-Sum in Java

## How to Sort the Gift Code in Java

The challenge Santa’s senior gift organizer Elf developed a way to represent up to 26 gifts by assigning a unique alphabetical character to each gift.… Read More »How to Sort the Gift Code in Java

## How to get the Numericals of a String in Java

You are given an input string. For each symbol in the string if it’s the first character occurrence, replace it with a ‘1’, else replace… Read More »How to get the Numericals of a String in Java

## How to “Dashatize It” in Java

The challenge Given a variable n, If n is an integer, Return a string with dash’-‘marks before and after each odd integer, but do not begin or end… Read More »How to “Dashatize It” in Java

## Comparing Array Multiplicities in Java

The challenge Given two arrays a and b write a function comp(a, b) (orcompSame(a, b)) that checks whether the two arrays have the “same” elements, with the same multiplicities. “Same” means, here,… Read More »Comparing Array Multiplicities in Java

## How to Find the Max Tree Node Value in Java

The challenge You are given a binary tree. Implement the method findMax which returns the maximal node value in the tree. For example, the maximum… Read More »How to Find the Max Tree Node Value in Java

## How to String Search with a Wildcard in Java

The challenge The method below is the most simple string search algorithm. It will find the first occurrence of a word in a text string.… Read More »How to String Search with a Wildcard in Java

## Get the Consonant Value in Java

The challenge Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters… Read More »Get the Consonant Value in Java

## Word Values Challenge in Java

The challenge Given a string “abc” and assuming that each letter in the string has a value equal to its position in the alphabet, our string will… Read More »Word Values Challenge in Java

## Sort Words by Position Index in Java

The challenge Your task is to sort a given string. Each word in the string will contain a single number. This number is the position… Read More »Sort Words by Position Index in Java

## How to install GraalVM on Mac

Install GraalVM with Homebrew Homebrew is the preferred way to install anything on your Mac. Install GraalVM without Homebrew Follow these 5 steps to get… Read More »How to install GraalVM on Mac

## How to Generate Random Integers with a Range in Java

Java comes with many different ways to generate random integers, even if you need to specify a lower and upper bound to constrain your required… Read More »How to Generate Random Integers with a Range in Java

## How to create ArrayList from Array in Java

The problem If you have a traditional array, that looks something like the following: And you would like to convert this to an ArrayList: ..then… Read More »How to create ArrayList from Array in Java

## How to Remove all Vowels from a String in Java

The challenge Remove all vowels from the string. Vowels: The solution in Java code Option 1: Option 2: Option 3: Test cases to validate our… Read More »How to Remove all Vowels from a String in Java

## How to Solve Max-Min Arrays in Java

The challenge You are given an array of unique elements, and your task is to rearrange the values so that the first max value is… Read More »How to Solve Max-Min Arrays in Java

## How to do Basic Encryption in Java

The challenge The most basic encryption method is to map a char to another char by a certain math rule. Because every char has an… Read More »How to do Basic Encryption in Java

## How to Find the Squares in Java

The challenge Complete the function that takes an odd integer (0 < n < 1000000) which is the difference between two consecutive perfect squares, and… Read More »How to Find the Squares in Java

## How to Get Longest Word in Sentence in Java

The challenge When given a string of space-separated words, return the word with the longest length. If there are multiple words with the longest length,… Read More »How to Get Longest Word in Sentence in Java

## Maximum Different of Int-Array in Java

The challenge You must implement a function that returns the difference between the biggest and the smallest value in a list(lst) received as a parameter.… Read More »Maximum Different of Int-Array in Java

## Indexed Capitalization in Java

The challenge Given a string and an array of integers representing indices, capitalize all letters at the given indices. Example: capitalize(“abcdef”,[1,2,5]) = “aBCdeF” capitalize(“abcdef”,[1,2,5,100]) =… Read More »Indexed Capitalization in Java