public static String commonPrefix(String a, String b) {
int i = 0;
while (i < a.length() && i < b.length() && a.charAt(i) == b.charAt(i))
++i;
return a.substring(0, i);
}
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #2000378 |
| Snippet name: | commonPrefix |
| Eternal ID of this version: | #2000378/1 |
| Text MD5: | 7458b1c05eaa9ba7bba684cd7ee0bbf2 |
| Author: | stefan |
| Category: | |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-06-22 20:56:16 |
| Source code size: | 199 bytes / 6 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 890 / 2331 |
| Referenced in: | [show references] |