A well formed java string -


a friend had interview question asking following:

given string comprising of characters (,),{,},[,], determine if formed or not.

in mind have answered no string , "/" character required print said characters. correct or way off base?

if well-formed means each brace closed matching brace , there no incidents ({)}, suggest use stack

  1. go through each character in string
  2. if opening brace, push on stack
  3. if closing brace, pop stack , look, if match -> if go through chars in string , stack empty, string formed

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -