Minimum Remove to Make Valid Parentheses
The Problem:
Given a string s of '(' , ')' and lowercase English characters.
Your task is to remove the minimum number of '(' or ')' in any positions so that the resulting parentheses string is valid and return any valid string.
Formally, a parentheses string is valid if and only if:
- It is the empty string, contains only lowercase characters, or
- It can be written as AB (A concatenated with B), where A and B are valid strings, or
- It can be written as (A), where A is a valid string.
Maximum Binary Tree
The Problem:
You are given an integer array 'nums' with no duplicates. A maximum binary tree can be built recursively from 'nums' using the following algorithm:
- Create a root node whose value is the maximum value in 'nums'.
- Recursively build the left subtree on the subarray prefix to the left of the maximum value.
- Recursively build the right subtree on the subarray suffix to the right of the maximum value.
Return the maximum binary tree built from 'nums'.
Verifying an Alien Dictionary
The Problem:
In an alien language, surprisingly they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.
Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographically in this alien language.
Minimum Remove to Make Valid Parentheses
The Problem:
Given a string s of '(' , ')' and lowercase English characters.
Your task is to remove the minimum number of '(' or ')' in any positions so that the resulting parentheses string is valid and return any valid string.
Formally, a parentheses string is valid if and only if:
- It is the empty string, contains only lowercase characters, or
- It can be written as AB (A concatenated with B), where A and B are valid strings, or
- It can be written as (A), where A is a valid string.
Maximum Binary Tree
The Problem:
You are given an integer array 'nums' with no duplicates. A maximum binary tree can be built recursively from 'nums' using the following algorithm:
- Create a root node whose value is the maximum value in 'nums'.
- Recursively build the left subtree on the subarray prefix to the left of the maximum value.
- Recursively build the right subtree on the subarray suffix to the right of the maximum value.
Return the maximum binary tree built from 'nums'.
Verifying an Alien Dictionary
The Problem:
In an alien language, surprisingly they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.
Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographically in this alien language.