We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Super Reduced String
- Discussions
Super Reduced String
Super Reduced String
Sort by
recency
|
44 Discussions
|
Please Login in order to post a comment
!/bin/python3
def superReducedString(s): # Write your code here stack = [] for char in s: if stack and stack[-1] == char: stack.pop() else: stack.append(char) reduced_string = ''.join(stack) return reduced_string if reduced_string else 'Empty String'
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
My answer in Python
Only three lines: Some practices in Hackerrank seem more difficult than easy and somes seem easier than intermediate.
def superReducedString(s): # Write your code here
Java O(n)