-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is unique branch #79
base: master
Are you sure you want to change the base?
Is unique branch #79
Conversation
Another solution without additional data structures but using objects, with performance O(N). function isUnique3(str){ let obj = {} for( let elem of str){ if(obj.hasOwnProperty(elem)) obj[elem]++ else obj[elem]=1 } for( key in obj){ if (obj[key]=== 1) return true else return false } } isUnique3('ada') // false isUnique3("golden") // true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
welcome!
This is a solution of this exercise using JS obejcts.
P.S. Am I supposed to run the mocha tests in my machine?
yes. that way you can quickly see if the algorithm as implemented solves the desired problem. in this case, the tests seem to not be passing, so it is likely that the solution is not correct :(
rather than returning an array, the function should return true
if all characters in the string are unique or false
otherwise (the name is a hint: isUnique
is something that hints at a yes/no answer).
THanks!
assert.equal(isUnique1("tech"), true); | ||
assert.equal(isUnique2("tech"), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.equal(isUnique1("tech"), true); | |
assert.equal(isUnique2("tech"), true); | |
assert.equal(isUnique("tech"), true); |
there's only one implementation in this file. same below.
@@ -1,3 +1,4 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like an unintended change in another person's file:
Hi,
This is a solution of this exercise using JS obejcts.
P.S. Am I supposed to run the mocha tests in my machine?
THanks!