-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompareTheTriplets.cs
More file actions
38 lines (33 loc) · 1.03 KB
/
CompareTheTriplets.cs
File metadata and controls
38 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProblemSolving_HackerRank_.Easy
{
public static class CompareTheTriplets
{
/// <summary>
/// Given two arrays of integers representing Alice's and Bob's ratings for various aspects,
/// compare their ratings and determine the winner.
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns>A list of two elements: the first list result, and the second list result.</returns>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static List<int> compareTriplets(List<int> a, List<int> b)
{
if (a.Count != b.Count)
throw new ArgumentException("Two lists must be the same size.");
var result1 = 0;
var result2 = 0;
for (int i = 0; i < a.Count; i++)
{
if (a[i] > b[i]) result1++;
if (a[i] < b[i]) result2++;
}
return new List<int>() { result1, result2 };
}
}
}