backtrack implementation for palindrom partitioining - leetcode problem