6 kyu
Hollow array
315 of 749aweleshetu
Description:
An array is said to be hollow if it contains 3
or more 0
s in the middle that are preceded and followed by the same number of non-zero elements. Furthermore, all the zeroes in the array must be in the middle of the array.
Write a function that accepts an integer array and returns true
if it is a hollow array, else false
.
Examples
[2, 3, 0, 0, 0, 5, 6] --> true
[2, 0, 0, 0, 5, 6] --> false // 1 nonzero to the left but 2 to the right
[2, 3, 0, 0, 5, 6] --> false // less than 3 zeroes in the middle
[0, 2, 0, 0, 0, 5, 6] --> false // 1 zero not in the middle
[0, 0, 0, 0, 0] --> true // 0 nonzero elements at both ends
[] --> false
Arrays
Fundamentals
Similar Kata:
Stats:
Created | Sep 11, 2017 |
Published | Sep 12, 2017 |
Warriors Trained | 1920 |
Total Skips | 75 |
Total Code Submissions | 11800 |
Total Times Completed | 749 |
JavaScript Completions | 315 |
TypeScript Completions | 76 |
C# Completions | 63 |
Python Completions | 324 |
C Completions | 21 |
Total Stars | 30 |
% of votes with a positive feedback rating | 87% of 244 |
Total "Very Satisfied" Votes | 194 |
Total "Somewhat Satisfied" Votes | 38 |
Total "Not Satisfied" Votes | 12 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |