Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5646
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4716
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Print Bracket Number
Easy Accuracy: 53.63% Submissions: 2048 Points: 2

Given a string S, the task is to find the bracket numbers.

Example 1:

Input:  S = "(aa(bdc))p(dee)â€‹"
Output: 1 2 2 1 3 3
Explanation: The highlighted brackets in
the given string (aa(bdc))p(dee) has been
assigned the numbers as: 1 2 2 1 3 3.


Example 2:

Input:  S = "(((()("
Output: 1 2 3 4 4 5
Explanation: The highlighted brackets in
the given string (((()( has been assigned
the numbers as: 1 2 3 4 4 5

Your task is to complete the function barcketNumbers() which takes a single string as input and returns a list of numbers. You do not need to take any input or print anything.

Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(|S|)

Constraints:
1 <= |S| <= 105

S contains lower case English alphabets, and '(', ')' characters
At any time the number of opening brackets are greater than closing brackets