Skip to content

Conversation

@shubhamdp
Copy link
Contributor

@shubhamdp shubhamdp commented Oct 5, 2019

Leetcode solutions for
2. Add Two Numbers
4. Median of Two Sorted Arrays
7. Reverse Integer
8. String to Integer (atoi)
21. Merge Two Sorted Lists
28. Implement strStr()

#249

@danghai
Copy link
Contributor

danghai commented Oct 6, 2019

Hi @shubhamdpatil , someone already resolved problems 7 and 8. Could you add your solution when you see your way is a different solution? I can merge when you resolve the conflict. Thank you

@@ -0,0 +1,37 @@
int strStr(char* haystack, char* needle) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think your way is brutal force. Do you come up with more efficient solution? It is a typical problem for pattern search. For example: Rabin Karp, KMP, or Horspool, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented this a year ago and I do not want to blindly implement an algorithm, so I'll need some time for that. It is up to you, you can merge this PR and I'll raise another one with the optimised solution to this problem or keep it open till I come up with another approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I raise a new pull request or add the kmp implementation to this pull request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, if you have the chance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I could not see my commits in mater branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can create a new one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll create a new PR qwith all the previous and will add KMP to it.

@danghai danghai merged commit 18181fc into TheAlgorithms:master Oct 7, 2019
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