[Coding Test Tips]Valid Parentheses

<Your Task>

  • Given a string with ‘(‘ and ‘)’
  • Write a function to validate if the string has the pair of ‘(‘ and ‘)’.

<Solution>

Step 1: Create a variable to count the length of the string
* Dividing by 2 is because you will loop through the string and remove the pair of ‘()’. If all pair match, it should end at (parens.length / 2) times

Step 2: Iterate and replace the pair with empty ‘’.

Living in an Asian country / 20 Aug 1990 / English writing & translating / Startup / Art / Photo / Movie / Book / Travel / Coffee…