Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.
Locked until you have predicted 4 outputs correctly.
| 1 | bool keep(char c) { |
| 2 | return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || |
| 3 | (c >= '0' && c <= '9'); |
| 4 | } |
| 5 | |
| 6 | char fold(char c) { |
| 7 | |
| 8 | if (c >= 'A' && c <= 'Z') { |
| 9 | return char(c - 'A' + 'a'); |
| 10 | } |
| 11 | |
| 12 | return c; |
| 13 | } |
| 14 | |
| 15 | bool solution(const string& s) { |
| 16 | |
| 17 | int n = s.size(); |
| 18 | int i = 0; |
| 19 | int j = n - 1; |
| 20 | |
| 21 | while (i < j) { |
| 22 | |
| 23 | while (i < j && !keep(s[i])) { |
| 24 | i++; |
| 25 | } |
| 26 | |
| 27 | while (i < j && !keep(s[j])) { |
| 28 | j--; |
| 29 | } |
| 30 | |
| 31 | if (fold(s[i]) != fold(s[j])) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | i++; |
| 36 | j--; |
| 37 | } |
| 38 | |
| 39 | return true; |
| 40 | } |
Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.