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

 

jebbert@volusia.k12.fl.us > quiz2021_10_12_SLHL_buttons
prev  |  next  |  chance

Write a method that returns how many "buttons" appear in an array of integers. A "button" is defined (for this problem) as an integer surrounded by integers that are one off from it. For example, in {43,44,43} 44 is a "button" because it is surrounded by two 43's, which are each one off from 44. In the array {124,532,533,534,535,235,532} 533 and 534 are both "buttons". The array input parameter could be any length and contain any integers (including positive, negative, and zero values). You may want to use one or more helper methods. Look at the test data for examples.


quiz2021_10_12_SLHL_buttons([21, 24, 25, 26, 39, 590, 421, 23, 50, 51, 52, 84, 235]) → 2
quiz2021_10_12_SLHL_buttons([5, -24]) → 0
quiz2021_10_12_SLHL_buttons([-21498]) → 0

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

public int quiz2021_10_12_SLHL_buttons(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: 250

Copyright Nick Parlante 2017 - privacy