CRX-Get BoardPath

I know the logic of this code,but i can’t understand the code. can u pls explain the code from line 22 to 27 with an example.
please explain in step by step

Hi @pajithpsap,
In your code initially there is a empty array list . So the loop will run 1 time as size of array list is 0. So in that one time ch will be added to the array list which is ‘a’.Hence now the length of the array List is 1 and the loop will run twice and the ch now is ‘b’ .So when i =0 the code will add b to the start of a as ba and then for i=1 it will add b to the end of a as ab … For the ch='c ’ the code will run 3 times as the size of array List is 2. So in the first i=0 the code will again run twice as the lenght of string ab and ba is 2. so the resulting arrayList will be cab and acb and abc … and for string ba it will be cba and bca and bac. So the final result will be [abc, bac, bca, acb, cab, cba].

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.