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...
Search Results
Searching for: loop
Individual Exercises
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...
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"...
We'll say that a "triple" in a string is a char appearing three times in a row. Return the number of triples in the given string. The...
We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right. Return true if all the...
Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are the same.
Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or...
Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more...
Given a string, return a string where every appearance of the lowercase word "is" has been replaced with "is not". The word "is" should...
Given two integers low
and high
representing a range, return the sum of the integers in that range. For example, if low
is 12 and high
is...
Given an integer num
, return the sum of the multiples of num
between 1 and 100. For example, if num
is 20, the returned value should be...
Given a String str
and a character ch
, return the number of times ch
appears in str
. For example, if str
is "Hello" and ch
is 'l', the...
Given an array of integers, return the sum of all values in the array.