Solve tree equality and valid parentheses
Company: Deutschebank
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Onsite
Quick Answer: This problem set evaluates core skills in data structures and algorithmic reasoning, specifically binary tree structural equality and bracket-matching for strings, testing understanding of tree traversal, recursion, and stack-based parsing.
Compare Binary Trees For Equality
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([1,[2,None,None],[3,None,None]], [1,[2,None,None],[3,None,None]])
Expected Output: True
Explanation: Same structure and values.
Input: ([1,[2,None,None],None], [1,None,[2,None,None]])
Expected Output: False
Explanation: Different structure is not equal.
Input: (None, None)
Expected Output: True
Explanation: Two empty trees are equal.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.
Validate Bracket String
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('()[]{}',)
Expected Output: True
Explanation: Every bracket closes correctly.
Input: ('([)]',)
Expected Output: False
Explanation: Incorrect nesting is invalid.
Input: ('',)
Expected Output: True
Explanation: The empty bracket string is valid.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.