I\'m doing the valid parenthesis program on leetcode and I came up with this solution but it uses extra memory and I\'m wondering if it\'s possible to reduce it to o(1) memo