Back to course home
0% completed
Vote For New Content
Solution: Removing Stars From a String
Problem Statement
Given a string s, where * represents a star. We can remove a star along with its closest non-star character to its left in a single operation.
The task is to perform as many such operations as possible until all stars have been removed and return the resultant string.
Examples
Example 1
- Input:
"abc*de*f" - Expected Output:
"abdf" - Description: We remove
calong with*to get"abde*f", then removeealong with*to get"abdf"
Example 2
- Input:
"a*b*c*d" - Expected Output:
"d" - Description: We remove
aalong with*to get
.....
.....
.....
Like the course? Get enrolled and start learning!