Java

How to Resolve Scaling Squared Strings in Java

The challenge You are given a string of n lines, each substring being n characters long. For example: s = “abcd\nefgh\nijkl\nmnop” We will study the “horizontal” and the “vertical” scaling of… Read More »How to Resolve Scaling Squared Strings in Java

Determine the Last Digits of N^2 == N in Java

The challenge Let’s call an integer number N ‘green’ if N² ends with all of the digits of N. Some examples: 5 is green, because 5² = 25 and 25 ends with 5. 11 is not green,… Read More »Determine the Last Digits of N^2 == N in Java

How to Map over a List of Lists in Java

The challenge Write a function which maps a function over the lists in a list: Example 1: Example 2: The solution in Java code Option… Read More »How to Map over a List of Lists in Java

How to Differentiate a Polynomial in Java

The challenge Create a function that differentiates a polynomial for a given value of x. Your function will receive 2 arguments: a polynomial as a string,… Read More »How to Differentiate a Polynomial in Java

Find the Sums of Perfect Squares in Java

The challenge The task is simply stated. Given an integer n (3 < n < 109), find the length of the smallest list of perfect squares which add up… Read More »Find the Sums of Perfect Squares in Java

How to Make a Spiral in Java

The challenge Your task, is to create a NxN spiral with a given size. For example, spiral with size 5 should look like this: 00000 ….0… Read More »How to Make a Spiral in Java

Find the Longest Common Subsequence in Java

The challenge from Wikipedia:The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences.It… Read More »Find the Longest Common Subsequence in Java

Determine if Number is a Power of Three in Java

The challenge Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such… Read More »Determine if Number is a Power of Three in Java

How to Count Binary Substrings in Java

The challenge Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0’s and 1’s, and all the 0’s… Read More »How to Count Binary Substrings in Java

Array Range between Integers in Java

The challenge Complete the function that takes two integers (a, b, where a < b) and return an array of all integers between the input parameters, including them.… Read More »Array Range between Integers in Java

Number of Rectangles in a Grid in Java

The challenge Given a grid of size m x n, calculate the total number of rectangles contained in this rectangle. All integer sizes and positions… Read More »Number of Rectangles in a Grid in Java

Longest vowel chain in Java

The challenge The vowel substrings in the word codewarriors are o,e,a,io. The longest of these has a length of 2. Given a lowercase string that has alphabetic characters… Read More »Longest vowel chain in Java

Determine Unique String Characters in Java

The challenge In this challenge, you will be given two strings a and b and your task will be to return the characters that are not common in the… Read More »Determine Unique String Characters in Java

Difference of Volumes of Cuboids in Java

The challenge In this simple exercise, you will create a program that will take two lists of integers, a and b. Each list will consist of 3 positive… Read More »Difference of Volumes of Cuboids in Java

Sort by binary ones in Java

The challenge In this example you need to implement a function that sort a list of integers based on it’s binary representation. The rules are… Read More »Sort by binary ones in Java

Binomial Expansion in Java

The challenge Write a program that can do some algebra. Write a function expand that takes in an expression with a single, one character variable, and expands… Read More »Binomial Expansion in Java

Consecutive strings in Java

The challenge You are given an array(list) strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array.… Read More »Consecutive strings in Java

Determine the Highest Scoring Word in Java

The challenge Given a string of words, you need to find the highest scoring word. Each letter of a word scores points according to its… Read More »Determine the Highest Scoring Word in Java

Solving Speed Control in Java

The challenge In John’s car the GPS records every s seconds the distance travelled from an origin (distances are measured in an arbitrary but consistent unit). For… Read More »Solving Speed Control in Java

Find the Greatest Common Divisor in Java

The challenge Find the greatest common divisor of two positive integers. The integers can be large, so you need to find a clever solution. The… Read More »Find the Greatest Common Divisor in Java