Skip non-alphanumeric characters03.07
Alphanumeric means letter or digit. Skipping non-alphanumeric means you still walk every index, but you act only when s[i] is in those ranges.
i increases every iteration whether you use s[i] or not. Punctuation and whitespace are visited and ignored. You do not jump over them.
Same skill, three traces. Read all three before you try it.
01mixed - given
s = "a12b"- walk
0: a keep1:1keep2:2keep3:bkeep- result
- kept:
a,1,2,b
02skip punctuation - given
s = "a,b"- walk
0: a keep1: , skip2:bkeep- result
- kept:
a,b
03skip none - given
s = "hello"- walk
every character is a letter
skipping is allowed to keep everything
- result
- kept:
h,e,l,l,o
walkAlnum(s).s is an ASCII string.Walk every index from left to right. Print
s[i] only when it is a letter or a digit. Still visit every index, even when you skip the print.On
"a12b" print a, 1, 2, b. On "a,b" print a, b. On "hello" print h, e, l, l, o.constraintss is a non-empty ASCII string of letters, digits, and punctuation.
- Valid Palindrome0/3 skills ready · two pointers · easyopen
- Valid Palindrome0/3 skills ready · two pointers · easyopen
Every Check with Awel is frozen here. Open one to read the code or load it back into the editor.