Skip to content

Instantly share code, notes, and snippets.

@abdulateef
Last active November 1, 2016 12:05
Show Gist options
  • Save abdulateef/0c06e3de306850a362bac3fc61120794 to your computer and use it in GitHub Desktop.
Save abdulateef/0c06e3de306850a362bac3fc61120794 to your computer and use it in GitHub Desktop.
Jim is off to a party and is searching for a matching pair of socks. His drawer is filled with socks, each pair of a different color. In its worst case scenario, how many socks (x) should Jim remove from his drawer until he finds a matching pair?
using System;
using System.Collections.Generic;
using System.IO;
class Solution {
static void Main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
// Console.WriteLine("Enter the Nmber of Test Case");
int Size = int.Parse(Console.ReadLine());
int[] input = new int[Size];
int i;
// Console.WriteLine("Enter Each Test");
for(i = 0; i < input.Length; i++)
{
input[i] = int.Parse(Console.ReadLine());
}
int[] output = new int[input.Length];
for (int k = 0; k < output.Length; k++)
{
output[k] = ((input[k]) + 1);
}
// Console.WriteLine("Worst Case Senarior");
for(int m = 0; m < Size; m++)
{
Console.WriteLine(output[m] + " ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment