![]() |
Given an expression exp of length n consisting of some brackets. The task is to print the bracket numbers when the expression is being parsed. Examples : Input : (a+(b*c))+(d/e) Output : 1 2 2 1 3 3 The highlighted brackets in the given expression (a+(b*c))+(d/e) has been assigned the numbers as: 1 2 2 1 3 3. Input : ((())(())) Output : 1 2 3 3 2 4 5 5 4 1 Source: Flipkart Interview Experience | Set 49. Approach :
Implementation: C++
Javascript
Output:
1 2 2 1 3 3
Time Complexity : O(n). |
Reffered: https://www.geeksforgeeks.org
Mathematical |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 7 |