Hacktoberfest Part #4 (4nd PR of release 0.2)

Fourth PR of release 0.2...

Pull Request #4
For the next 2 pull requests I decided to stay in the same repository. For 4th PR I chose the string algorithm of finding the longest common substring. It was a little bit challenging to understand the logic of how to find it.

Logic of my algorithm:

  • The idea is we get 2 strings from the input, first and second
  • If first bigger then second we swap them
  • Then we need to iterate trough the second string, to find pieces of different sizes (from 1 to size of string) from first sting in the second string
  • Once we find any piece from first string in the second string we return it
  • The process continues until first string exists
  • If string do not have any common substrings then program returns empty string
After that I wrote this code and tests for it:



And created the pull request:
https://github.com/manrajgrover/algorithms-js/pull/60

Comments

Popular posts from this blog

Release 0.3 - PR2

Hacktoberfest Final Blog Post

Release 0.4 - PR3