Redacted transcript
EasyOnline Assessment
Produce the public version of a call transcript in which sensitive parts have been marked for redaction.
A < starts a redaction and a > ends the most recently started redaction that is still open, so redactions can be nested (<a<b>c> is one redaction in total, hidden from the first < to the last >). Every character inside a redaction is hidden, and so are the < and > markers that delimit it. Two more rules:
- A
>that arrives when no redaction is open does not close anything; it is an ordinary character and stays visible. - A
<that is never closed hides everything from that point to the end of the text.
Input: text, a string.
Output: a string, the visible text with every other character kept in its original order. If everything is hidden (or text is empty), return "".
Example 1
- Input:
- ["Dear <Ms. Okafor>, your balance is ready."]
- Output:
- "Dear , your balance is ready."
- Explanation
<Ms. Okafor>is one redaction. It disappears completely, markers included, so the text on either side is joined asDear , your balance is ready..
Example 2
- Input:
- ["Call <555-<01>-99> now"]
- Output:
- "Call now"
- Explanation
- The redaction opened at
<555-is still open when<01>opens and closes inside it, so the first>only closes the inner one. The outer redaction ends at the second>. Everything from the first<to there is hidden, leavingCall now.
Example 3
- Input:
- ["a>b<c"]
- Output:
- "a>b"
- Explanation
- The
>afteracloses nothing, so it stays as a normal character. The final<is never closed, so it and everything after it (c) is hidden.
Constraints
0 <= text.length <= 10,000textcontains printable ASCII characters, including spaces