PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Pinterest

Determine equality of arbitrarily nested sets

Last updated: May 13, 2026

Quick Overview

This question evaluates understanding of nested data structures and set semantics, including canonicalization, hashing, recursion, handling of edge cases, unit-test design, and time/space complexity analysis.

  • Medium
  • Pinterest
  • Coding & Algorithms
  • Software Engineer

Determine equality of arbitrarily nested sets

Company: Pinterest

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Implement a function that determines whether two arbitrarily nested sets are equal. Sets are unordered and contain no duplicates; elements can be integers or other sets. Inputs are given as nested arrays representing sets (e.g., [1,[2,3],4]). Your solution must handle unlimited nesting depth. Choose and justify suitable data structures, describe the algorithm, and analyze time/space complexity. Include unit tests for the following cases: set1=[1,[2,3],4], set2=[1,[3,4],2] -> false; set1=[1,[2,3],4], set2=[1,4,[2,3]] -> true. Discuss trade-offs such as canonicalization vs. hashing vs. recursion with memoization, and cover edge cases (empty sets, duplicates in input encoding, very deep nesting).

Quick Answer: This question evaluates understanding of nested data structures and set semantics, including canonicalization, hashing, recursion, handling of edge cases, unit-test design, and time/space complexity analysis.

Related Interview Questions

  • Design Hierarchical Permission Checks - Pinterest (medium)
  • Implement weighted random choice - Pinterest (medium)
  • Solve five hard algorithm problems - Pinterest
  • Sample a string by real-valued scores - Pinterest (hard)
  • Find First Prefix-Matching Word - Pinterest (medium)
Pinterest logo
Pinterest
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
10
0

Implement a function that determines whether two arbitrarily nested sets are equal. Sets are unordered and contain no duplicates; elements can be integers or other sets. Inputs are given as nested arrays representing sets (e.g., [1,[2,3],4]). Your solution must handle unlimited nesting depth. Choose and justify suitable data structures, describe the algorithm, and analyze time/space complexity. Include unit tests for the following cases: set1=[1,[2,3],4], set2=[1,[3,4],2] -> false; set1=[1,[2,3],4], set2=[1,4,[2,3]] -> true. Discuss trade-offs such as canonicalization vs. hashing vs. recursion with memoization, and cover edge cases (empty sets, duplicates in input encoding, very deep nesting).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Pinterest•More Software Engineer•Pinterest Software Engineer•Pinterest Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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.