Instantly share code, notes, and snippets.

Embed
What would you like to do?
MISQUERY ONLINE
WITH RECURSIVE solve(strrow,str) AS (
SELECT str,str
FROM tbl
UNION ALL
SELECT strrow,REPLACE(REPLACE(REPLACE(str, '()', ''),'{}',''),'[]','')
FROM solve
WHERE str!=REPLACE(REPLACE(REPLACE(str, '()', ''),'{}',''),'[]','')
)
SELECT i,
CASE WHEN str IN
(
SELECT strrow
FROM solve
WHERE str = ''
) THEN 'YES'
ELSE 'NO'
END AS judgement
FROM tbl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment