Company: Tavant technologies_15nov
Difficulty: medium
String Validation Problem Description You are given one line containing a stream of characters made of groups and garbage . A group starts with { and ends with } . A group holds zero or more items separated by commas, and each item is either another group or a block of garbage, so groups nest. A } closes the most recently opened group that is still open. Garbage starts with [ and ends with ] . Almost anything can sit between those brackets, including { , } and [ . Inside garbage, [ has no special meaning and never opens a second block. Inside garbage, ! cancels the single character that follows it . The cancelled character is ignored completely, whatever it is - including ] , [ and another ! . Neither the ! nor the character it cancels is counted. Compute two numbers: 1. Total score. The outermost group scores 1. A group nested directly inside another scores one more than the group containing it. The total score is the sum over all groups. 2. Non-cancelled characters. The number of cha