Last active
September 22, 2020 15:26
-
-
Save vmamore/2ff1f2f31f787244a8143c73ded30495 to your computer and use it in GitHub Desktop.
Revisions
-
vmamore revised this gist
Sep 22, 2020 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ static int sockMerchant(int n, int[] ar) { var hashSet = new HashSet<int>(); int pairs = 0; -
vmamore revised this gist
Sep 22, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // https://www.hackerrank.com/challenges/sock-merchant/problem?h_l=interview&playlist_slugs%5B%5D%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D%5B%5D=warmup // Complete the sockMerchant function below. static int sockMerchant(int n, int[] ar) { var hashSet = new HashSet<int>(); -
vmamore renamed this gist
Sep 22, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
vmamore created this gist
Sep 22, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ // Complete the sockMerchant function below. static int sockMerchant(int n, int[] ar) { var hashSet = new HashSet<int>(); int pairs = 0; for(int i = 0; i < n; i ++){ if(!hashSet.Contains(ar[i])) { hashSet.Add(ar[i]); } else { pairs++; hashSet.Remove(ar[i]); } } return pairs; }