Exercises

0.0 / 50

Write a function in Java that implements the following logic: Given 2 ints, a and b, return their sum. However, sums in the range 10..19...

0.0 / 50

Write a function in Java that implements the following logic: Given three ints, a b c, return true if one of them is 10 or more less than...

0.0 / 50

Write a function in Java that implements the following logic: Given a number n, return true if n is in the range 1..10, inclusive. Unless...

0.0 / 50

Write a function in Java that implements the following logic: We are having a party with amounts of tea and candy. Return the int outcome...

0.0 / 50

Write a function in Java that implements the following logic: Given three ints, a, b, and c, return true if b is greater than a, and c is...

0.0 / 50

Write a function in Java that implements the following logic: Given a string and an int n, return a string made of n repetitions of the...

0.0 / 50

Given two int arrays a and b, each with two elements, return a new array with four elements containing all the elements of a followed by...

0.0 / 50

Given an int array of any length, return a new array of its first 2 elements. If the array is smaller than length 2, use whatever...

0.0 / 70

Given an integer array length of 1 or more, return the difference between the largest and smallest values in the array. Note that the...

0.0 / 70

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...

0.0 / 70

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...

0.0 / 70

Given an array of ints, return true if the number of 1s is greater than the number of 4s. Otherwise, return false.

0.0 / 70

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...

0.0 / 70

Given an array of ints, if it contains no 1's return true. If it contains no 4's, return true. If it contains both, return false.

0.0 / 70

Given an array of ints, 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.

0.0 / 70

Given an array of ints, return true if the array contains two 7s next to each other, or there are two 7s separated by one element, such...

0.0 / 70

Given an array of ints, return true if there is a 1 in the array with a 2 somewhere later in the array.

0.0 / 70

Given an array of ints, return true if the value 3 appears in the array exactly 3 times, and no 3s are next to each other.

0.0 / 70

Given an array of ints, return true if every 2 that appears in the array is next to another 2. Otherwise, return false.

0.0 / 90

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...

0.0 / 90

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...

0.0 / 90

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....

0.0 / 90

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...

0.0 / 50

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...

0.0 / 50

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...

0.0 / 30

Given a string of any length, return a new string where the last 2 chars, if present, are swapped, so "coding" yields "codign".

0.0 / 30

Given a string, return true if "bad" appears starting at index 0 or 1 in the string, such as with "badxxx" or "xbadxx" but not "xxbadxx"....

0.0 / 50

Return a version of the given string, where for every star (*) in the string the star and the character immediately to its left and the...

0.0 / 50

Return true if somewhere in the array, there are three increasing adjacent numbers like .... 4, 5, 6, ... or 23, 24, 25.

0.0 / 50

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...

0.0 / 50

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...

0.0 / 50

Given a non-empty array of ints, return a new array containing the elements from the original array that come after the last 4 in the...

0.0 / 70

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...

0.0 / 50

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...

0.0 / 70

Given two arrays of ints sorted in increasing order, called outer and inner, return true if all of the numbers in inner also appear in ...

0.0 / 70

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...

0.0 / 30

Given a string, return a new string made of 3 copies of the last 2 chars of the original string. The string's length will be at least 2.

...
0.0 / 30

Given a string, return the string made of its first two chars, so the string "Hello" yields "He". If the string is shorter than length 2,...

0.0 / 50

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....

0.0 / 50

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...

0.0 / 20

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...

0.0 / 10

Use appropriate method calls from the List ADT to create the following list: < 4 19| 23 30 > You should assume that L is passed to...

0.0 / 10

Use a single assignment statement to make the variable p refer to the Node with info '2' given that the list contains [1,2,3] and points...

0.0 / 50

Write a member method balanceBags in Java that implements the following logic: Given a String parameter the methods returns the String...