Solved LeetCode program · 5 of 1,000
#0005 · Longest Palindromic Substring
Original English source
The word is "babad". The last is the last position of word. The best is empty text.
For every start from 0 to last.
For every finish from start to last.
The piece is the slice of word from start to one more than finish. The reversed is empty text. For every step from 0 to finish minus start, The position is finish minus step, Place character position of word into reversed. The piecelength is the length of piece. The bestlength is the length of best. If piece is reversed, if piecelength is greater than bestlength, set best to piece.
Report best.
Expected stdout
bab