Given an array of int
s, return true
if the sum of all the 2's in the array is exactly 8.
Search Results
Searching for: enhanced for loop
Individual Exercises
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...
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...
Say that a "clump" in an array is a series of 2 or more adjacent elements of the same value. Return the number of clumps in the given...
Given an array, return an array that contains exactly the same numbers as the original array, but rearranged so that every 4 is...
Given a string str
and an int n
, return a string made of the first n
characters of the string, followed by the first n - 1
characters of...
Return an array that contains the exact same numbers as the given array, but rearranged so that all the even numbers come before all the...
Given n
>= 0, create an array with the pattern {1, 1, 2, 1, 2, 3, ... 1, 2, 3 .. n
} (spaces added to show the grouping). Note that...
Given a string of any length, return a new string where the last 2 chars, if present, are swapped, so "coding" yields "codign".
Return true
if somewhere in the array, there are three increasing adjacent numbers like .... 4, 5, 6, ... or 23, 24, 25.
Given start
and end
integers, return a new array containing the sequence of integers from start
up to but not including end
, so start
= 5...