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...
Search Results
Individual Exercises
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...
Return an array that is "left shifted" by one--so for an input of {6, 2, 5, 3}, the method returns {2, 5, 3, 6}. You may modify and...
Given a non-empty array of int
s, return a new array containing the elements from the original array that come after the last 4 in the...
We'll say that an element in an array is "alone" if there are values before and after it, and those values are different from it. Return...
Return an array that contains the exact same numbers as the given array, but rearranged so that all the zeros are grouped at the start of...
Given two arrays of int
s sorted in increasing order, called outer
and inner
, return true
if all of the numbers in inner
also appear in ...
Given n
>= 0, create an array of length n * n
with the following pattern, shown here for n
= 3 : {0, 0, 1, 0, 2, 1, 3, 2, 1} (spaces...
Given two strings, word
and a separator sep
, return a big string made of count
occurrences of the word
, separated by the separator...
Given a day of the week encoded as 0 = Sun, 1 = Mon, 2 = Tue, ... 6 = Sat, and a boolean indicating if we are on vacation, return a...
The number 6 is a truly great number. Given two int
values, a
and b
, return true if either one is 6. Or if their sum or difference is 6....
When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40...
You and your date are trying to get a table at a restaurant. The parameter you
is the stylishness of your clothes, in the range 0..10,...
You have a green lottery ticket, with int
s a
, b
, and c
on it. If the numbers are all different from each other, the result is 0. If all...
Write a method called listUpper()
that takes in a list of strings, and returns a list of the same length containing the same strings but...
Write a method called listSearch()
that takes in a target string and a list of other strings. This method returns a (possibly shorter)...
Write a method called listLength()
that takes in a list of strings and returns a list of their lengths as integers. You must create a new...
Given a string, return a string where for every char in the original, there are two chars.
Given a string, compute a new string by moving the first char to come after the next two chars, so "abc" yields "bca". Repeat this...
Returns true if for every '*' (star) in the string, if there are chars both immediately before and after the star, they are the same.
Given two strings, base
and remove
, return a version of the base
string where all instances of the remove
string have been removed (not...
Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not"...