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

 

crehwinkel@frhsd.com post-exam-problems > countLeadingZeros
prev  |  next  |  chance

Write a method countLeadingZeros which is passed an array of integers and which returns a count of the number of leading zeros in the array. For example if the array {0,0,0,5,3,9,0,2} was passed to the method, the value of 3 would be returned. If an empty array is passed to the method, it should return 0.


countLeadingZeros([0, 0, 0, 5, 3, 0, 9]) → 3
countLeadingZeros([1, 2, 3, 4]) → 0
countLeadingZeros([0, 0, 8, 2, 4, 1, 0, 0, 0, 66, 9]) → 2

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

public int countLeadingZeros(int [] arr){ }

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: 200

Copyright Nick Parlante 2017 - privacy