solve generate parentheses, regular expression matching and search insert position