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

 

gaurav.gupta@mq.edu.au arraylists > isNiceOrder
prev  |  next  |  chance

NOTE: This problem is deliberately phrased to be convoluted/complex. Sometimes we are given problem statements that could be phrased a lot simpler, and it takes a bit of analysis to see that the problem is not as complex as it looks. This is an exercise in the same. Define a function that when passed an ArrayList of Integer objects, returns true if it is in a "nice" order, and false otherwise. A "nice" order is defined as an order where each item that is not at the two ends, is higher than or equal to one of its neighbour, and lower than or equal to the other.


isNiceOrder([10, 70, 20, 90]) → false
isNiceOrder([10, 20, 20, 40]) → true
isNiceOrder([40, 40, 20, 20, 10]) → true

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

boolean isNiceOrder(ArrayList<Integer> list) { }

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: 4 Post-solution available

Copyright Nick Parlante 2017 - privacy