We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sales by Match
Sales by Match
Sort by
recency
|
5954 Discussions
|
Please Login in order to post a comment
This is my solution using C#.
Solution for Python3
` def sockMerchant(n, ar): # Write your code here arCount = Counter(ar) pairCount = 0
`
In java 8:
public static int sockMerchant(int n, List ar) { // Write your code here Integer pairs = 0; int i = 0; while(i < (ar.size() - 1)) { Integer sock = ar.get(i); for(int j = i+1; j < ar.size(); j++){ if(sock == ar.get(j)){ pairs++; ar.remove(i); ar.remove(j - 1); break; }
}
Here is my c++ solution , you can find the video explanation here : https://youtu.be/HPIhFXx_DVM
Python 3:
Ruby: