Leaf-Similar Trees
Updated
Problem statement
The leaf sequence of a tree lists leaf values from left to right. Return whether root1 and root2 have identical leaf sequences.
Function
leafSimilar(root1: TreeNode, root2: TreeNode) → booleanExamples
Example 1
root1 = [1,2,3]root2 = [7,2,3]return = trueBoth trees have the leaf sequence [2,3].
Constraints
- Each tree contains between
1and10000nodes. - Node values fit in a signed 32-bit integer.
More Atlassian Online Assessment questions
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Count Parent Nodes With a Target SumAdobe · OAAdobe interview questions
- Max Minus Min Weight in Every SubtreeHudson River Trading · OAHudson River Trading interview questions
- Employee SubordinatesInMobi · OAInMobi interview questions
- Preorder, Inorder and Postorder of a Binary TreeCapital One · OA · ONSITE INTERVIEWCapital One interview questions
- Minimum Leaf Path Sum over All RootsInfosys · OAInfosys interview questions
- Count Prime Values in SubtreesVisa · OAVisa interview questions
- Palindromic Paths to the RootRippling · OARippling interview questions
- Part 2: Batch Access ReviewScale AI · OAScale AI interview questions
- Sum Dynamic Weighted Tree DistancesJuspay · OA
- Sewer Drainage PartitionTwo Sigma · OATwo Sigma interview questions