## Find the first non-consecutive number in Java

The challenge Your task is to find the first element of an array that is not consecutive. By not consecutive we mean not exactly 1… Read More »Find the first non-consecutive number in Java

The challenge Your task is to find the first element of an array that is not consecutive. By not consecutive we mean not exactly 1… Read More »Find the first non-consecutive number in Java

The challenge altERnaTIng cAsE <=> ALTerNAtiNG CaSe Define String.prototype.toAlternatingCase (or a similar function/method such as to_alternating_case/toAlternatingCase/ToAlternatingCase in your selected language; see the initial solution for details) such that each lowercase letter… Read More »Alternating String Casing in Java

The challenge Given an array of 3 integers a, b and c, determine if they form a pythagorean triple. A pythagorean triple is formed when: c2 =… Read More »Solving the Pythagorean Triple in Java

The challenge Character recognition software is widely used to digitise printed texts. Thus the texts can be edited, searched and stored on a computer. When… Read More »How to Correct the Mistakes of the Character Recognition Software in Java

The challenge The objective of Duck, duck, goose is to walk in a circle, tapping on each player’s head until one is chosen. Task: Given an array of… Read More »Solving “Duck Duck Goose” in Java

The challenge Write function avg which calculates average of numbers in given list. The solution in Java code Option 1 (working through the problem): Option… Read More »Calculate averages from an int array in Java

Rotating a String in Java is a common interview question, and albeit it quite a simple one, it tests many fundamental concepts. Did I mention… Read More »How to Rotate a String in Java

The challenge Sum all the numbers of the array except the highest and the lowest element (the value, not the index!).(The highest/lowest element is respectively… Read More »Calculate the Sum without highest and lowest number in Java

Java makes it easy to convert a string to an array by providing the built-in .split() method on the String object. The challenge Write a… Read More »How to Convert a String to an Array in Java

The challenge Create a function that will return a string that combines all of the letters of the three inputed strings in groups. Taking the… Read More »How to Loop and Combine Three Strings in Java

The challenge The medians of a triangle are the segments that unit the vertices with the midpoint of their opposite sides. The three medians of… Read More »How to Localize The Barycenter of a Triangle in Java

The challenge Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square. The coordinate of a point pi is represented as [xi, yi].… Read More »How to Calculate a Valid Square in Java

The challenge Everybody knows the classic “half your age plus seven” dating rule that a lot of people follow (including myself). It’s the ‘recommended’ age range in… Read More »How to Calculate Age Range Compatibility as an Equation in Java

The challenge Let’s call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length – 1 such… Read More »How to Find the Longest Mountain in Array in Java

chmod alters the permissions for a file or directory, you could allow full read/write access to a file or directory by running the following command:… Read More »How to tell what the CHMOD value of a file/directory is

The challenge Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is… Read More »How to Solve the “Decode a String” Challenge in Java

You may find your /var/log/journal directory taking up a lot of disk-space. How do you go about removing, or deleting all these files without the… Read More »How to cleanup a /var/log/journal in Linux

The challenge Given the root of a binary tree, find the maximum value V for which there exist different nodes A and B where V = |A.val – B.val| and A is an ancestor of B. A node A is an ancestor… Read More »How to Find the Maximum Difference Between Node and Ancestor in Java

The challenge Create a function that finds the integral of the expression passed. In order to find the integral all you need to do is add one… Read More »How to Find the Integral using Java

The challenge Write a function stringy that takes a size and returns a string of alternating ‘1s’ and ‘0s’. The string should start with a 1. A string with size 6 should return :’101010′. With size 4 should return… Read More »How to Build Strings from a Size in Java

The challenge Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to… Read More »Best Time to Buy and Sell Stock in Java

The challenge Write a method, that will get an integer array as parameter and will process every number from this array.Return a new array with… Read More »How to Solve the “To square(root) or not to square(root)” Challenge in Java

The challenge “A divisibility rule is a shorthand way of determining whether a given integer is divisible by a fixed divisor without performing the division,… Read More »Solving the Rule of Divisibility by 13 in Java

The challenge Given two strings A and B of lowercase letters, return true if you can swap two letters in A so the result is equal to B, otherwise, return false. Swapping letters is defined… Read More »How to Calculate Buddy Strings in Java

The challenge Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image… Read More »How to Flip a Binary Matrix in Java