Solved LeetCode program · 993 of 1,000
#1371 · Find the Longest Substring Containing Vowels in Even Counts
Original English source
Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared masks as an empty list of whole numbers.
For every letter from 0 to 25.
Place 0 into masks.
Set item 0 of masks to 1. Set item 4 of masks to 2. Set item 8 of masks to 4. Set item 14 of masks to 8. Set item 20 of masks to 16. Keep a shared earliest as an empty list of whole numbers.
For every state from 0 to 31.
Place -2 into earliest.
Keep a shared wanted as empty text. Keep a shared slot of 0.
To rank. The spot is 0.
Repeat while spot is at most 25.
If the slice of alphabet from spot to spot plus 1 matches wanted, set slot to spot, return. Add 1 to spot.
The word is "eleetminicoworoep". The last is the last position of word. Set item 0 of earliest to -1. Keep a shared state of 0. The best is 0.
For every position from 0 to last.
The symbol is the slice of word from position to position plus 1. Set wanted to symbol. Rank. The at is slot. The bit is item at of masks. The current is state. Set state to exclusive or of current and bit. The fresh is state. The start is item fresh of earliest. If start is less than -1, set item fresh of earliest to position. If start is at least -1, The span is position minus start, If span is more than best, set best to span.
Show best.
Expected stdout
13