-
Notifications
You must be signed in to change notification settings - Fork 20k
Removing Arrays.fill() or for loops, added longest common substring #2027
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
…fills the array with 0s As pointed out by @prashantdoshi28
Added Longest Common substring of two strings
Revert "Added Longest Common substring of two strings"
@@ -0,0 +1,27 @@ | |||
public class LongestCommonSubstring { |
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.
Can you please add problem statement and other relevant info.
@@ -14,7 +14,7 @@ public FloydWarshall(int numberofvertices) { | |||
[numberofvertices | |||
+ 1]; // stores the value of distance from all the possible path form the source | |||
// vertex to destination vertex | |||
Arrays.fill(DistanceMatrix, 0); | |||
// here the distanceMatrix is initialized by 0s b default upon initialization with new keyword |
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.
Good, thanks for considering this 👍
Hey @icoder211 , what I meant by add relevant info is that add comment in code explaining problem and document your code so anyone from watching your code, can understand why you did what you did. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions! |
Removed Arrays.fill() because new keyword initializes a 2D array of int's with 0s, as pointed out by @prashantdoshi28
The longest common substring problem:
Given two strings, "S" and "T", find the length of the longest common substring between the two strings
A "substring" of a string "S" is that string, with any number of characters (0 or more) deleted from the front of S, and any number of characters (0 or more) deleted from the end of S.
A common substring of two strings S and T is any substring s of S and substring t of T, such that s = t.
Output the length longest such common substring.
Sample test case:
S = "abbaf"
T = "abcdef"
Sample output:
2
Explanation:
The common substrings are:
"ab"
"a"
"b"
"f"
The longest among them is "ab", of length 2.
References
Checklist:
Fixes: #{$ISSUE_NO}
.