Solved LeetCode program · 867 of 1,000
#1177 · Can Make Palindrome from Substring
Original English source
Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared symbol as empty text. Keep a shared position of 0. Keep a shared odd of 0. Keep a shared mask of 0. Keep a shared source as empty text. Place "abcda" into source.
To locate from spot (a whole number). The letter is the slice of alphabet from spot to spot plus 1. If letter matches symbol, set position to spot, return. Locate from spot plus 1.
To count from left (a whole number) with right (a whole number). Set odd to 0. Set mask to 0.
For every spot from left to right.
The piece is the slice of source from spot to spot plus 1. Set symbol to piece. Locate from 0. The bit is shift 1 left by position. The was is bitwise and of mask and bit. If was is more than 0, subtract 1 from odd. If was is 0, add 1 to odd. Set mask to exclusive or of mask and bit.
The queries is a list of 3, 3, 0, 1, 2, 0, 0, 3, 1, 0, 3, 2, 0, 4, and 1.
For every query from 0 to 4.
The left is item (query times 3) of queries. The right is item (query times 3 plus 1) of queries. The budget is item (query times 3 plus 2) of queries. Count from left with right. The pairs is odd divided by 2. If pairs is at most budget, show true, otherwise show false.
Expected stdout
true false false true true