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 characters
| public boolean isUnique(string str) { | |
| for(int i=0; i<str.size(); i++){ | |
| for(int j=0; j<str.size(); j++) { | |
| if(i==j) continue; | |
| else if(str.charAt(j) == str.charAt(i)) return false; | |
| } | |
| } | |
| return true; | |
| } |
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 characters
| public boolean inUnique(string str) { | |
| boolean[] chars = new boolean[256]; // Size only works with ASCII, increase otherwise. | |
| for(int i=0; i<str.size(); i++){ | |
| if(chars[str.charAt(i)]) return false; | |
| chars[str.charAt(i)] = true; | |
| } | |
| return true; | |
| } |
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 characters
| def fizzbuzz(n): | |
| for i in xrange(1, n+1): print [i, 'Fizz', 'Buzz', 'FizzBuzz'][(i%3 == 0) + 2 * (i % 5 == 0)] |
NewerOlder