Write a function in Java that implements the following logic: Given a string str
and a non-empty word
, return a string made of each...
Search Results
Searching for: logic
Individual Exercises
Write a function in Java that counts the number of times the string "code" appears anywhere in the given string str
, except that we'll...
Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case...
Write a function in Java that returns true if the given string str
contains an occurrence of the substring "xyz" where "xyz" is not...
We'll say that a string is xy-balanced if for all the 'x' characterss in the string, there exists a 'y' character somewhere later in the...
A sandwich is two pieces of bread with something in between. Write a Java method that takes in a string str
and returns the string that...
Write a function in Java that takes an int
array as its parameter and returns the number of even int
s it contains. Note: the %
"mod"...
Write a function in Java that takes an int
array as its parameter. It should return the sum of the numbers in the array, except ignore...
We'll say that a value is "everywhere" in an array if for every pair of adjacent elements in the array, at least one of the pair is that...
Given two arrays of the same length, nums1
and nums2
, for every element in nums1
, consider the corresponding element in nums2
(at the...
Write a function in Java that returns a version of the given array where all the 10's have been removed. The remaining elements should...
Write a function in Java that takes an array and returns the sum of the numbers in the array, or 0 if the array is empty. Except the...
Given an array of int
values, return true if the array contains either 3 even or 3 odd values all next to each other.
For each multiple of 10 in the given array, change all the values following it to be that multiple of 10, until encountering another...
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 int
s, return a new array containing the elements from the original array that come before the first 4 in the...
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, does "xyz" appear in the middle of the string? To define middle, we'll say that the number of chars to the left and right...
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...
We have bunnies standing in a line, numbered 1, 2, ... The odd bunnies (1, 3, 5, ...) have the normal 2 ears. The even bunnies (2, 4,...
Given a non-negative int n
, return the sum of its digits recursively (no loops). Note that mod (%
) by 10 yields the rightmost digit (126...
Given a non-negative int n
, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8...
Given an array of int
s, compute recursively the number of times that the value 11 appears in the array (no loops). We'll use the...