Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //find if string has unique chars...
- Object.assign(String.prototype, {
- HasUniqueChars(){
- for(let i =0; i < this.length; i++){
- for(let j =i+1; j < this.length; j++){
- if(this[i] == this[j])
- return false;
- }
- }
- return true;
- }
- });
- console.log("abcd".HasUniqueChars()); // true
- console.log("abccd".HasUniqueChars()); // false
- //Big(O) = n*n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement