-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
added an algo which finds unique element in an array #1359
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
added an algo which finds unique element in an array #1359
Conversation
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.
- Get rid of the changes to
package.json
orpackage-lock.json
. - This is not a general solution as the name currently suggests. It only works if (1) there is exactly one unique element (2) all duplicate elements occur an even number of times.
- This can be written more concisely as
arr.reduce((acc, val) => acc ^ val, 0)
.
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.
- Please use a proper JSDoc comment (and don't phrase it as "if the interviewer asks" etc.; that's fluff that should be omitted).
- By "get rid of the changes to
package.json
andpackage-lock.json
" I meant remove the changes to them from this PR, not remove the files.
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.
Please use proper JSDoc comments.
Describe your change:
Checklist:
Example:
UserProfile.js
is allowed butuserprofile.js
,Userprofile.js
,user-Profile.js
,userProfile.js
are notFixes: #{$ISSUE_NO}
.