PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

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.

  • hard
  • Deutschebank
  • Coding & Algorithms
  • Software Engineer

Solve tree equality and valid parentheses

Company: Deutschebank

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

You are asked to solve **two independent coding questions**. ## 1) Compare two binary trees for equality Given the roots of two binary trees `p` and `q`, return `true` if they are **structurally identical** and all corresponding nodes have the **same value**; otherwise return `false`. **Input:** Two tree roots `p`, `q` (each node has `val`, `left`, `right`). **Output:** Boolean. **Constraints (typical):** - `0 <= number_of_nodes <= 10^4` - Node values fit in 32-bit signed integer. ## 2) Validate bracket/parentheses string Given a string `s` consisting only of the characters `'(' , ')' , '{' , '}' , '[' , ']'`, determine whether the input string is **valid**. A string is valid if: 1. Open brackets are closed by the **same type** of brackets. 2. Open brackets are closed in the **correct order**. 3. Every close bracket has a corresponding earlier open bracket. **Input:** String `s`. **Output:** Boolean. **Constraints (typical):** - `0 <= |s| <= 10^5` ## Additional requirement After implementing each solution, write a few **test cases** that cover normal cases and edge cases.

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

Trees are represented as [value,left,right] or None. Return whether two trees have identical structure and values.

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

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.

Validate Bracket String

Return whether a bracket string is valid with matching bracket types and order.

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

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.