FastPrepLeaf-Similar Trees
Problems/Leaf-Similar Trees

Leaf-Similar Trees

Atlassian logoAtlassian● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Atlassian full-time online assessment. The report links to the exact Leaf-Similar Trees exercise but does not copy its full statement. Our version follows that linked exercise and uses a fixed function interface.

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) → boolean

Examples

Example 1

root1 = [1,2,3]root2 = [7,2,3]return = true
root1
123
root2
723

Both trees have the leaf sequence [2,3].

Constraints

  • Each tree contains between 1 and 10000 nodes.
  • 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

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public boolean leafSimilar(TreeNode root1, TreeNode root2) {
      // Write your code here.
    }

}
Checking account…