Libraryless. Click here for Pure Java version (3808L/22K).
1 | sS longestCommonSubstringIC(S s1, S s2) { |
2 | int Start = 0; |
3 | int Max = 0; |
4 | int l1 = l(s1), l2 = l(s2); |
5 | for ping (int i = 0; i < l1; i++) { |
6 | for ping (int j = 0; j < l2; j++) { |
7 | int x = 0; |
8 | while (eqic(s1.charAt(i + x), s2.charAt(j + x))) { |
9 | x++; |
10 | if ((i + x) >= l1 || (j + x) >= l2) break; |
11 | } |
12 | if (x > Max) { |
13 | Max = x; |
14 | Start = i; |
15 | } |
16 | } |
17 | } |
18 | ret s1.substring(Start, Start + Max); |
19 | } |
Began life as a copy of #1012478
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032817 |
Snippet name: | longestCommonSubstringIC |
Eternal ID of this version: | #1032817/3 |
Text MD5: | 8a6e71d0d09fe0d15aacdc4e22af805a |
Transpilation MD5: | 533b574227137f4c4073be65541e0405 |
Author: | stefan |
Category: | javax / strings |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-06 11:28:25 |
Source code size: | 462 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 149 / 211 |
Version history: | 2 change(s) |
Referenced in: | [show references] |