Sunday, March 13, 2016

HackerRank: string algorithm - Make it anagram

March 13, 2016


Make it anagram

Julia's practice:
C# language

https://gist.github.com/jianminchen/050b64f483c9a251d472

Read other's submission:

1. C#, using Dictionary, HashSet - Speically helpful, when you are not sure what Latin chars are. You just declare in general Dictionary, HashSet.

https://gist.github.com/jianminchen/5c6f6a70a1be4f71a98a

2. C#, using List class, remove method:

https://gist.github.com/jianminchen/a2258616e596c0328660

3. C#, kind of functional programming, new style to Julia - like JavaScript programming style

https://gist.github.com/jianminchen/2909916d9435f69c036b

4. using one array, first string each char - add to the array, second string each char - take away from the array, sum of abs value of each item.
https://gist.github.com/jianminchen/fbf8e9049d3a1539ee87

5. Using IList interface, distinct method, and functional programming - Lambda Expression <- Julia, you should try this code by yourself. It should be quickly picked up.

https://gist.github.com/jianminchen/fc8b4309efe00d67a640

read this webpage to refresh Lambda expression:
https://msdn.microsoft.com/en-CA/library/bb397687.aspx

6. Sort two strings first, and then, using two pointers - sliding forward

https://gist.github.com/jianminchen/41e6cbd30228e9ba7204

7. using string operation, remove a char from a string - for any char in both two strings
https://gist.github.com/jianminchen/0138e2425592638dcf7a









No comments:

Post a Comment