screenshot.else you get downvote.   grouping of round and square sections is given. You can change the arrangement by playing out the accompanying activities: shift the bearing of a section from opening to shutting as well as the other way around without changing the type of the section: for example you can change '(' to ')' and ')' to '('; you can change '[' to ']' and ']' to '['. The activity costs 0 burles.  change any square

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

In c++ code. Correct code and output screenshot.else you get downvote.

 

grouping of round and square sections is given. You can change the arrangement by playing out the accompanying activities: shift the bearing of a section from opening to shutting as well as the other way around without changing the type of the section: for example you can change '(' to ')' and ')' to '('; you can change '[' to ']' and ']' to '['. The activity costs 0 burles. 

change any square section to adjust section having a similar course: for example you can change '[' to '(' yet not from '(' to '['; comparably, you can change ']' to ')' however not from ')' to ']'. The activity costs 1 burle. The activities can be acted in any request quite a few times. You are given a string s of the length n and q inquiries of the kind "l r" where 1≤l<r≤n. For each substring s[l… r], track down the base expense to pay to make it a right section grouping. It is ensured that the substring s[l… r] has an even length. 

 

The inquiries should be handled autonomously, for example the progressions made in the string for the response to an inquiry I don't influence the inquiries j (j>i). At the end of the day, for each question, the substring s[l… r] is given from the at first given string s. A right section grouping is an arrangement that can be worked agreeing the accompanying principles: an unfilled grouping is a right section succession; on the off chance that "s" is a right section grouping, the successions "(s)" and "[s]" are right section arrangements. 

in the event that "s" and "t" are right section arrangements, the grouping "st" (the link of the successions) is a right section arrangement. 

 

For example the arrangements "", "(()[])", "[()()]()" and "(())()" are right section groupings while "(", "[(])" and ")))" are not. 

Info :The principal line contains one whole number t (1≤t≤100) — the quantity of experiments. Then, at that point, t experiments follow. For each experiment, the main line contains a non-void string s containing just round ('(', ')') and square ('[', ']') sections. The length of the string doesn't surpass 106. The string contains no less than 2 characters.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning