Madan Shekar

Madan Shekar

  • 206
  • 8.3k
  • 1.1m

Qucick Help Needed COUNT Curly braces in string

Apr 27 2019 11:35 PM
Hi
 
i will get one string, in that string i have to count pair of curly braces. bellow is an example of data .
 
please give me solutions for this .
 
{}, score of 1.
{{{}}}, score of 1 + 2 + 3 = 6.
{{},{}}, score of 1 + 2 + 2 = 5.
{{{},{},{{}}}}, score of 1 + 2 + 3 + 3 + 3 + 4 = 16.
{<a>,<a>,<a>,<a>}, score of 1.
{{<ab>},{<ab>},{<ab>},{<ab>}}, score of 1 + 2 + 2 + 2 + 2 = 9.
{{<!!>},{<!!>},{<!!>},{<!!>}}, score of 1 + 2 + 2 + 2 + 2 = 9.
{{<a!>},{<a!>},{<a!>},{<ab>}}, score of 1 + 2 = 3.

Answers (7)