-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Create 0187-repeated-dna-sequences.js #2557
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
Conversation
Added a solution for repeated-dna-sequences in JS.
}; | ||
|
||
function getSubSequance(s,i,len) { | ||
return s.slice(i, i + len); |
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.
Suggestion: This will change your time complexity. Refactor or review your Time O()
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.
Hmm, the len parameter is a constent(10 in this case). so the the time complexity would be 10*n which is still n right? Aren't we suppose to ignore the coefficient? But I have changed the time coplexity in the comment nonetheless.
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.
You are right! Since it is a constant, we can ignore the auxiliary space.
Updated Time complexity.
|
||
var findRepeatedDnaSequences = function(s) { | ||
|
||
const sequanceStack = new Set(); |
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.
The variable names are misleading
const sequenceSet = new Set();
const resultSet = new Set();
return [ ...resultSet ];
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.
Oh, my bad. Sorry. I updated the variables.
Updated variable names.
Fix conflict |
Hey @aakhtar3 there seems to be added code to mine. I didn't write it. Do you want me to keep this code in the file? var findRepeatedDnaSequences = function (s) {
}; |
Hey @aakhtar3, this is just a kind reminder. Let me know what should I do with the additional added code. |
You can add both solutions |
Oh, ok I'll do that. |
fixing conflict. adding alternative code.
The conflict is resolved. |
Added a solution for repeated-dna-sequences in JS.
File(s) Added: 0187-repeated-dna-sequences.js
Language(s) Used: JavaScript
Submission URL: https://leetcode.com/problems/repeated-dna-sequences/submissions/984603175/