1 | static int countChar(S s, char c) { |
2 | int n = 0, l = l(s), i = 0; |
3 | while true { |
4 | int j = s.indexOf(c, i); |
5 | if (j < 0) break; |
6 | ++n; |
7 | i = j+1; |
8 | } |
9 | ret n; |
10 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003598 |
Snippet name: | countChar - count occurrences of a character in a string |
Eternal ID of this version: | #1003598/2 |
Text MD5: | 47c965e384b5f539a54eff67f3e36f99 |
Author: | stefan |
Category: | javaqx |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-03 14:07:07 |
Source code size: | 177 bytes / 10 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 615 / 1170 |
Version history: | 1 change(s) |
Referenced in: | [show references] |