Skip to content

Week 4 Array#24

Open
Samju200 wants to merge 3 commits intomainfrom
week-4
Open

Week 4 Array#24
Samju200 wants to merge 3 commits intomainfrom
week-4

Conversation

@Samju200
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@IreneNakiyingi IreneNakiyingi left a comment

Choose a reason for hiding this comment

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

Function search (line 28) is missing execution of a condition; otherwise return -1;

nums.sort;
let i = nums.indexOf(target);
return i;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Irene stated a condition that you missed here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also the question requires that You must write an algorithm with O(log n) runtime complexity. This solution does not satisfy that requirement even though it works. You might want to check that out

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also the question requires that You must write an algorithm with O(log n) runtime complexity. This solution does not satisfy that requirement even though it works. You might want to check that out

Okay
Done, Thank you

Copy link
Collaborator

Choose a reason for hiding this comment

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

This solution is O(n) time complexity. Look up Binary search and view some examples with various solutions as Mary suggested, will help a lot in understanding.

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.

3 participants