markdown guide
 

I have done like this:

bool validateBrackets(const std::string& data) {

  std::stack<char> brackets;  

  for (const auto& d : data) {
    if (d == '[' || d == '(' || d == '{') {
      brackets.push(d);
    }      
    else if (d == ']') {
     if (brackets.top() == '[')
       brackets.pop(); 
      else 
        return false;
    }
    else if (d == ')') {
     if (brackets.top() == '(')
       brackets.pop();
      else 
        return false;
    }
    else if(d == '}') {
     if (brackets.top() == '{')
       brackets.pop();
      else 
        return false;
    }
  }

  return true;
}

 

yasss πŸ‘πŸ‘ I like the direct comparison for the bracket pairings. More efficient than a map 😬😁

Classic DEV Post from Aug 21 '18

Dockerise your Nuxt SSR App like a boss! (A True Vue Vixens story) [Part 1]

Packing your apps doesn't have to be a titanic task!

creator profile image
I aim to create immersive experiences which augment perspective. AR/iOS