Young Coders: Week 4 Problems


The Final Challenges!

1) Create a method called between. Its parameter is an int array. It will return the maximum distance between any two equal values. 

For example:
between(new int[] {1,0,4,2,5,0,0,5})
should return 6, because the leftmost 0 and the rightmost 0 are 6 elements apart (including themselves). 




2) Create a method called checkIncrease. Its parameter is an int array. Return true if the ints are strictly increasing. 

{1,2,3,4} --> true
{1,1,1,4,5} --> false

3) Create a method called happyTriplet. Its parameter is a String array. Return true if there are three Strings in a row that are equivalent. 

{"Penguin", "Duck", "Duck", "Duck"} returns true. 

BONUS! 

Two parts to this challenge: solve it both recursively and iteratively...

Given a number, return the product of its digits. 

BONUS 2!

Create a method called makeUnique. Its parameter is an int array, input. Return another array made up of the unique values from input (in any order). 

Example: 
{4,4,6,2,6,2,6,22} --> {4,6,2,22} 

Popular posts from this blog

Space Race: a simple Rust game built on the Bevy framework

Building a Toy Language Compiler in Go

tldr: Raft + Implementation Tips