Error
|
|
---|---|
@Ibrahim Nash | 5765 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4993 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1286 |
@bt8816103042 | 739 |
@rohitanand | 495 |
@codeantik | 479 |
@shalinibhataniya1097 | 472 |
@amrutakashikar2 | 464 |
@thealchemist627 | 456 |
@akashkale117 | 453 |
@shivanandp12345678910 | 453 |
@dalwainazism125 | 453 |
@SherlockHolmes3 | 447 |
Complete Leaderboard |
Given a string that contains ternary expressions. The expressions may be nested. You need to convert the given ternary expression to a binary Tree and return the root.
Input Format:
First line of input contains of test case T. The only line of test case consists of String s.
Outpu Format:
Preorder traversal of Tree formed
Your Task:
This is a function problem, you don't need to read input/output. Just complete the function convertExpression that take string and index(initialized from 0) as parameters.
Constraints:
1 <= T <= 100
1 <= |String| <= 100
Example:
Input:
2
a?b:c
a?b?c:d:e
Output:
a b c
a b c d e
Explanation:
Testcase1:
Input : string expression = a?b:c
Output : a
/ \
b c
Testcase2:
Input : expression = a?b?c:d:e
Output : a
/ \
b e
/ \
c d
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes