String

String DSA Question Swift

Reverse words in String

[Question] Given a string s, reverse the words of the string.Note: Remove extra spaces from output Examples: Example 1: Input: s=”My Name is Janesh” Output: “Janesh is Name My” Example 2: Input: s= ” My Name is Janesh” Output: “Janesh is Name My”

 Remove Outermost Parentheses || String

[Question]: A valid parentheses string is either empty “”, “(” + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, “”, “()”, “(())()”, and “(()(()))” are all valid parentheses strings. Return s after removing the outermost parentheses of every primitive string in the primitive decomposition of s. Example 1: Input: s = “(()())(())” Output: “()()()” Explanation: The input string …

 Remove Outermost Parentheses || String Read More »