Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public static class Kata
- {
- public static int[] ArrayLeaders(int[] numbers)
- {
- List<int> listOfnums = new List<int>();
- int elementSum = 0;
- for(int x = 0;x < numbers.Length;x++)
- {
- if(x + 1 < numbers.Length)
- {
- for(int y = x + 1;y < numbers.Length;y++)
- {
- elementSum += numbers[y];
- }
- }
- if(x + 1 >= numbers.Length)
- {
- elementSum = 0;
- }
- if(elementSum < numbers[x])
- {
- listOfnums.Add(numbers[x]);
- }
- }
- int[] result = listOfnums.ToArray();
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement