Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1032817 // longestCommonSubstringIC

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3808L/22K).

sS longestCommonSubstringIC(S s1, S s2) {
  int Start = 0;
  int Max = 0;
  int l1 = l(s1), l2 = l(s2);
  for ping (int i = 0; i < l1; i++) {
    for ping (int j = 0; j < l2; j++) {
      int x = 0;
      while (eqic(s1.charAt(i + x), s2.charAt(j + x))) {
        x++;
        if ((i + x) >= l1 || (j + x) >= l2) break;
      }
      if (x > Max) {
        Max = x;
        Start = i;
      }
    }
  }
  ret s1.substring(Start, Start + Max);
}

Author comment

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: 148 / 210
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1032818 - longestCommonSubstringsIC [not good like this]