Skip to content

Instantly share code, notes, and snippets.

@ricardoparro
Created January 16, 2016 23:22
Show Gist options
  • Save ricardoparro/6ddc978a48056a50edc9 to your computer and use it in GitHub Desktop.
Save ricardoparro/6ddc978a48056a50edc9 to your computer and use it in GitHub Desktop.
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