Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int SolveP1(int[] data)
- {
- int increases = 0;
- for (int i = 0; i < data.Length - 1; i++)
- {
- if (data[i + 1] > data[i])
- {
- increases++;
- }
- }
- return increases;
- }
- public static int SolveP2(int[] data)
- {
- int[] arr = new int[data.Length];
- for (int i = 0; i < data.Length - 1; i++)
- {
- for (int j = i; j < i + 3; j++)
- {
- if (j == data.Length) { return SolveP1(arr); }
- arr[i] += data[j];
- }
- }
- return -1;
- }
Add Comment
Please, Sign In to add comment