7 kyu

Array Leaders (Array Series #3)

631 of 8,351MrZizoScream

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 side

  • Note : 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 side

  • 5 is greater than the sum all the elements to its right side

  • Note : 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 side

  • 2 is greater than the sum all the elements to its right side

  • Note : 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 side

  • 3 is greater than the sum all the elements to its right side

  • Note : 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

Fundamentals
Arrays

Stats:

CreatedJan 21, 2018
PublishedJan 22, 2018
Warriors Trained13342
Total Skips937
Total Code Submissions22616
Total Times Completed8351
C++ Completions631
Python Completions2352
JavaScript Completions2920
C Completions168
Java Completions1033
Haskell Completions98
C# Completions369
Ruby Completions178
PHP Completions211
Julia Completions22
Dart Completions254
CoffeeScript Completions14
Crystal Completions7
TypeScript Completions209
Elixir Completions55
Reason Completions5
Prolog Completions21
Clojure Completions31
Rust Completions177
Total Stars155
% of votes with a positive feedback rating94% of 1344
Total "Very Satisfied" Votes1209
Total "Somewhat Satisfied" Votes116
Total "Not Satisfied" Votes19
Total Rank Assessments4
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • MrZizoScream Avatar
  • donaldsebleung Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • B1ts Avatar
  • rsa Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • xondre09 Avatar
  • Phares Avatar
  • hobovsky Avatar
  • cliffstamp Avatar
  • stellartux Avatar
  • RobsonMoon Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • akar-0 Avatar
  • XoRMiAS Avatar
  • saudiGuy Avatar
Ad