Problem statement:
Difficulty: Moderate
More C# solution:
Solution 1:
Julia, here is code you should study; more advanced than yours.
a person works for Box Inc.
https://www.hackerrank.com/__run
https://gist.github.com/jianminchen/576ecf2cd127a703cb7a
Learn C# coding: readonly, Equals, override, constructor, use byte instead of int.
Solution 2:
use Dictionary class, string key for anagram string, use getHashCode() call to turn key as Int.
https://gist.github.com/jianminchen/ffcca0582b5f0d1d6a9b
Read about getHashCode() webpage:
https://msdn.microsoft.com/en-us/library/system.object.gethashcode(v=vs.110).aspx
Solution 3:
https://gist.github.com/jianminchen/8f6bd4631f0b5f0bdee7
Solution 4.
use Dictionary class, sort the key string, then anagram strings will be the same.
https://gist.github.com/jianminchen/59e326cbd1d8910c01c7
solution 5:
Excellent code, written by a programmer in salesforce.com
https://www.hackerrank.com/rest/contests/w13/challenges/sherlock-and-anagrams/hackers/rosharyg/download_solution
Julia likes the code:
https://gist.github.com/jianminchen/d2ccf6532524d8751c73
Solution 6: <- simple and quick, it can be written in less than 20 minutes. But not time efficient! O(n^2 * string length)
Use brute force, 3 loops, and then define anagramChecking function, just basic array, simple and quick.
https://gist.github.com/jianminchen/9f381875942d468ccb00
No comments:
Post a Comment