Skip to content

Conversation

AHTHneeuhl
Copy link
Contributor

Important

Please make sure the file name is lowercase and a duplicate file does not already exist before merging.

* @return {number}
*/
var singleNonDuplicate = function (nums) {
let l = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: name descriptive variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code. Can you check this PR as well

#2692

Thanks

@AHTHneeuhl AHTHneeuhl requested a review from aakhtar3 July 13, 2023 18:09
while (left <= right) {
const mid = (left + right) >> 1;

if (nums[mid] === nums[mid ^ 1]) left = mid + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: This is a more advanced binary search. You are using mid and mid + 1. This small tweak can used in m bitonic arrays. Better to define the comparison to indicate that.

const mid1 = ((left + right) >> 1);
const mid2 = (mid ^ 1);

@AHTHneeuhl AHTHneeuhl requested a review from aakhtar3 July 13, 2023 21:05
@aakhtar3 aakhtar3 merged commit 8439788 into neetcode-gh:main Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants