id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jan30_2020_SLHL_increasingSomehow


Write a method that accepts an array of positive integers. Starting at position zero in the array, return the number of numbers that "increase somehow". Once the first number does not "increase somehow" you are done. So what does "increase somehow" mean? Suppose we have an array {57,140,250,164,3} 140>57 so that was an increase. 250>140 so that was an increase. 164<250 so that would not normally be considered an increase, but this is where the "somehow" comes in! The other way a number can be considered as "increasing somehow" is for more than half of the digits to have increased compared to the corresponding digits in the same position of the original number. So since two out the three digits increased, that is still considered "increasing somehow". But there is no way that the 3 can be considered as increasing, so there are THREE increases. Note that {40,70} is considered to have ONE increase. It is not about how many numbers there are in the increasing sequence, but rather how many increases there are.


jan30_2020_SLHL_increasingSomehow([52421, 352, 325, 214, 436, 643]) → 0
jan30_2020_SLHL_increasingSomehow([]) → 0
jan30_2020_SLHL_increasingSomehow([5]) → 0

...Save, Compile, Run (ctrl-enter)

public int jan30_2020_SLHL_increasingSomehow(int nums[]) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy