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

 

quiz2022_03_09_APSLHL_flop


Write a method that returns the "flopped" version of the input array 'nums'. A "flopped" array is one such that elements of the array are replaced with the highest valued element that has occurred so far in the array. For example, the array {5,7,2,3,8,11,4,1}, when "flopped" becomes {5,7,7,7,8,11,11,11}. The reason is that by the time you get to index 0, the highest value that happened so far is 5. But then when you get to index 1, the highest value so far becomes 7. Since index 2 and 3 are less than 7, they get replaced with 7 because that is the highest value so far. This process continues through the remainder of the array. Look at the test data for additional examples. Please note that the input array 'nums' can contain ANY number of numbers AND can contain any valid integers.


quiz2022_03_09_APSLHL_flop([5, 7, 2, 3, 8, 11, 4, 1]) → [5, 7, 7, 7, 8, 11, 11, 11]
quiz2022_03_09_APSLHL_flop([50, 25, 100, 50, 200, 100, 500, 250, 505]) → [50, 50, 100, 100, 200, 200, 500, 500, 505]
quiz2022_03_09_APSLHL_flop([]) → []

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

public int[] quiz2022_03_09_APSLHL_flop(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: 230

Copyright Nick Parlante 2017 - privacy