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

10
LINES

< > BotCompany Repo | #1013597 - commonSuffix

JavaX fragment (include)

sS commonSuffix(S a, S b) {
  int i = 0, nb = b.length(), na = a.length(), n = min(na, nb);
  while (i < n && a.charAt(na-1-i) == b.charAt(nb-1-i))
    ++i;
  return i == nb ? b : substring(a, na-i);
}

sS commonSuffix(Iterable<S> l) {
  ret commonSuffixMulti(l);
}

Author comment

Began life as a copy of #2000379

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1013597
Snippet name: commonSuffix
Eternal ID of this version: #1013597/2
Text MD5: ef0b6169ebad7d6030eb5d1602263060
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-02 13:11:00
Source code size: 274 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 202 / 222
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1013597 & http://1013597.tinybrain.de