Libraryless. Click here for Pure Java version (2343L/15K).
// set must be a case-insensitive set // set must not contain empty string static int substringsScoreIC_optimized1(S s, Set<S> set) { int maxLength = lengthOfLongestString(set); int n = l(s); Set<S> seen = ciSet(); for i to n: { int k = min(i+maxLength, n); for (int j = i+1; j <= k; j++) { S sub = substring(s, i, j); if (set.contains(sub)) seen.add(sub); } } ret l(seen); }
Began life as a copy of #1027490
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027514 |
| Snippet name: | substringsScoreIC_optimized1 - how many elements of a list are substrings of a string? [dev.] |
| Eternal ID of this version: | #1027514/3 |
| Text MD5: | 196522928a127314d3ec6dbd531890eb |
| Transpilation MD5: | d89160877cef9552606d885f06544368 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-22 17:13:33 |
| Source code size: | 434 bytes / 16 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 394 / 514 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |