You are viewing a single comment's thread. Return to all comments →
In C# 100%
public static void countApplesAndOranges(int s, int t, int a, int b, List<int> apples, List<int> oranges) { int appleCount = 0; foreach (int distance in apples) { int landingPosition = a + distance; if (landingPosition >= s && landingPosition <= t) { appleCount++; } } int orangeCount = 0; foreach (int distance in oranges) { int landingPosition = b + distance; if (landingPosition >= s && landingPosition <= t) { orangeCount++; } } Console.WriteLine(appleCount); Console.WriteLine(orangeCount); } }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
In C# 100%