Array Leaders (Array Series #3)
Description:
Introduction and Warm-up (Highly recommended)
Playing With Lists/Arrays Series
Definition
An element is leader if it is greater than The Sum all the elements to its right side.
Task
Given an array/list [] of integers , Find all the LEADERS in the array.
Notes
Array/list size is at least 3 .
Array/list's numbers Will be mixture of positives , negatives and zeros
Repetition of numbers in the array/list could occur.
Returned Array/list should store the leading numbers in the same order in the original array/list .
Input >> Output Examples
arrayLeaders ({1, 2, 3, 4, 0}) ==> return {4}
Explanation:
4
is greater than the sum all the elements to its right sideNote : The last element
0
is equal to right sum of its elements (abstract zero).
arrayLeaders ({16, 17, 4, 3, 5, 2}) ==> return {17, 5, 2}
Explanation:
17
is greater than the sum all the elements to its right side5
is greater than the sum all the elements to its right sideNote : The last element
2
is greater than the sum of its right elements (abstract zero).
arrayLeaders ({5, 2, -1}) ==> return {5, 2}
Explanation:
5
is greater than the sum all the elements to its right side2
is greater than the sum all the elements to its right sideNote : The last element
-1
is less than the sum of its right elements (abstract zero).
arrayLeaders ({0, -1, -29, 3, 2}) ==> return {0, -1, 3, 2}
Explanation:
0
is greater than the sum all the elements to its right side-1
is greater than the sum all the elements to its right side3
is greater than the sum all the elements to its right sideNote : The last element
2
is greater than the sum of its right elements (abstract zero).
Playing with Numbers Series
Playing With Lists/Arrays Series
For More Enjoyable Katas
ALL translations are welcomed
Enjoy Learning !!
Zizou
Similar Kata:
Stats:
Created | Jan 21, 2018 |
Published | Jan 22, 2018 |
Warriors Trained | 13342 |
Total Skips | 937 |
Total Code Submissions | 22616 |
Total Times Completed | 8351 |
C++ Completions | 631 |
Python Completions | 2352 |
JavaScript Completions | 2920 |
C Completions | 168 |
Java Completions | 1033 |
Haskell Completions | 98 |
C# Completions | 369 |
Ruby Completions | 178 |
PHP Completions | 211 |
Julia Completions | 22 |
Dart Completions | 254 |
CoffeeScript Completions | 14 |
Crystal Completions | 7 |
TypeScript Completions | 209 |
Elixir Completions | 55 |
Reason Completions | 5 |
Prolog Completions | 21 |
Clojure Completions | 31 |
Rust Completions | 177 |
Total Stars | 155 |
% of votes with a positive feedback rating | 94% of 1344 |
Total "Very Satisfied" Votes | 1209 |
Total "Somewhat Satisfied" Votes | 116 |
Total "Not Satisfied" Votes | 19 |
Total Rank Assessments | 4 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |