Created
January 16, 2016 23:22
-
-
Save ricardoparro/6ddc978a48056a50edc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
//https://community.topcoder.com/stat?c=problem_statement&pm=7558 | |
public class AdvertisingAgency | |
{ | |
static public void Main(string[] args) | |
{ | |
int[] requests = new[]{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, | |
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, | |
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, | |
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, | |
100, 100, 100, 100, 100, 100, 100, 100, 100, 100 | |
}; | |
int result = numberOfRejections(requests); | |
Console.WriteLine("result: " + result); | |
Console.ReadLine(); | |
} | |
static public int numberOfRejections(int[] arrayOfRequests){ | |
int[] billboards = new int[101]; | |
int rejections = 0; | |
foreach (var req in arrayOfRequests) | |
{ | |
if(billboards[req] != 0) | |
rejections++; | |
else | |
billboards[req] = req; | |
} | |
return rejections; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment