Solved LeetCode program · 87 of 1,000
#0087 · Scramble String
Original English source
The firsttext is "great". The secondtext is "rgeat". The size is 5. The width is 6. The table is a list of 150 zeros.
For every first from 0 to 4.
For every second from 0 to 4.
If character first of firsttext is character second of secondtext, set item ((first times 5 plus second) times 6 plus 1) of table to 1.
For every length from 2 to 5.
For every first from 0 to (5 minus length).
For every second from 0 to (5 minus length).
For every split from 1 to length minus 1.
The base is (first times 5 plus second) times 6. The splitindex is base plus split. The noother is (first plus split) times 5 plus second plus split. The nootherindex is noother times 6 plus length minus split. The swapother is first times 5 plus second plus length minus split. The swapotherindex is swapother times 6 plus split. The swapbase is (first plus split) times 5 plus second. The swapbaseindex is swapbase times 6 plus length minus split. The noswap is 0. If item splitindex of table is 1 and item nootherindex of table is 1, set noswap to 1. The withswap is 0. If item swapotherindex of table is 1 and item swapbaseindex of table is 1, set withswap to 1. The fullindex is base plus length. If noswap is 1 or withswap is 1, set item fullindex of table to 1.
If item 5 of table is 1, show true. Otherwise, show false.
Expected stdout
true