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

10
LINES

< > BotCompany Repo | #1013597 // commonSuffix

JavaX fragment (include)

1  
sS commonSuffix(S a, S b) {
2  
  int i = 0, nb = b.length(), na = a.length(), n = min(na, nb);
3  
  while (i < n && a.charAt(na-1-i) == b.charAt(nb-1-i))
4  
    ++i;
5  
  return i == nb ? b : substring(a, na-i);
6  
}
7  
8  
sS commonSuffix(Iterable<S> l) {
9  
  ret commonSuffixMulti(l);
10  
}

Author comment

Began life as a copy of #2000379

download  show line numbers  debug dex  old transpilations   

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

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: 303 / 347
Version history: 1 change(s)
Referenced in: [show references]