Given a number n
, create and return a new int
array of length n
, containing the numbers 0, 1, 2, ... n-1. The given n
may be 0, in which...
Exercises
Given a number n
, create and return a new string array of length n
, containing the strings "0", "1" "2" .. through n-1. N
may be 0, in...
Given an array of int
s, return true
if the array contains a 2 next to a 2 somewhere.
Given an array of int
s, return true
if the array does not contain any 1s or 3s. Otherwise, return false
.
Given an array of int
s, return true
if the sum of all the 2's in the array is exactly 8.
Given an array of int
s, return true
if the number of 1s is greater than the number of 4s. Otherwise, return false
.
Given an array of ints, return true
if every element is either a 1 or a 4. Otherwise, return false
.
Consider the series of numbers beginning at start
and running up to but not including end
, so for example start=1 and end=5 gives the...
Given an array of int
s, if it contains no 1's return true
. If it contains no 4's, return true
. If it contains both, return false
.
Given an array of int
s, return true
if the array contains a 2 next to a 2 or a 4 next to a 4, but not both. Otherwise, return false
.
Given an array of int
s, return true
if the array contains two 7s next to each other, or there are two 7s separated by one element, such...
Given an array of int
s, return true
if there is a 1 in the array with a 2 somewhere later in the array.
Given an array of int
s, return true
if the value 3 appears in the array exactly 3 times, and no 3s are next to each other.
Given an array of int
s, return true
if every 2 that appears in the array is next to another 2. Otherwise, return false
.
Given a non-empty array, return true
if there is a place to split the array so that the sum of the numbers on one side is equal to the...
Consider the leftmost and righmost appearances of some value in an array. We'll say that the span is the number of elements between the...
Return an array that contains exactly the same numbers as the given array but re-arranged so that every 3 is immediately followed by a 4....
We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears...
For this problem, we'll round an int
value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20....
We want make a package of goal
kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of...
Given a string, if the same 2-character substring appears at both its beginning and end, return the contents of the string without the...
Given a string of even length, return the first half. So the string "WooHoo" yields "Woo".
Write a function in Java that implements the following logic: Return a version of the given array where each zero value in the array is...
Given a non-empty array of type int
, return a new array containing the elements from the original array that came before thefirst 4 in...
Given an array of int
values, return true if the group of n
numbers at the start of the array is the same as the group of n
numbers at...