PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Pinterest

Solve Expression and Tree-List Problems

Last updated: Jun 22, 2026

Quick Overview

This question evaluates competency in string expression generation under a custom left-to-right evaluation rule and in-place binary search tree manipulation to form a sorted doubly linked list, covering expression evaluation, digit concatenation constraints, and pointer-based data structure transformations.

  • medium
  • Pinterest
  • Coding & Algorithms
  • Machine Learning Engineer

Solve Expression and Tree-List Problems

Company: Pinterest

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

The coding portion included two algorithm problems: 1. **Generate expressions with left-to-right evaluation** Given a string `num` containing only digits and an integer `target`, insert the operators `+` and `*` between some digits, or choose to concatenate adjacent digits into multi-digit numbers. Return all expressions that evaluate to `target`. Unlike normal arithmetic, expressions are evaluated strictly from left to right, with no operator precedence. For example, `2+3*2` is evaluated as `(2+3)*2 = 10`. Additional constraints: - Do not generate numbers with leading zeros unless the number itself is exactly `0`. - Return every valid expression. 2. **Convert a binary search tree into a sorted doubly linked list** Given the root of a binary search tree, rearrange the existing nodes in place to form a sorted, non-circular doubly linked list. Use each node's `left` pointer as `prev` and `right` pointer as `next`. The head of the list should be the smallest value. Follow-up: given the head of the resulting sorted doubly linked list, insert a new node while keeping the list sorted.

Quick Answer: This question evaluates competency in string expression generation under a custom left-to-right evaluation rule and in-place binary search tree manipulation to form a sorted doubly linked list, covering expression evaluation, digit concatenation constraints, and pointer-based data structure transformations.

Related Interview Questions

  • Hierarchical Access Control for an Advertising Platform - Pinterest (medium)
  • First Word Matching Each Prefix Query - Pinterest (medium)
  • Maximize Boxes Stored Through One Entrance - Pinterest (medium)
  • Solve Multiple Coding Interview Problems - Pinterest (medium)
  • Implement a Sparse Matrix Class - Pinterest (medium)
Pinterest logo
Pinterest
Feb 21, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
11
0
Loading...

The coding portion included two algorithm problems:

  1. Generate expressions with left-to-right evaluation Given a string num containing only digits and an integer target , insert the operators + and * between some digits, or choose to concatenate adjacent digits into multi-digit numbers. Return all expressions that evaluate to target . Unlike normal arithmetic, expressions are evaluated strictly from left to right, with no operator precedence. For example, 2+3*2 is evaluated as (2+3)*2 = 10 . Additional constraints:
    • Do not generate numbers with leading zeros unless the number itself is exactly 0 .
    • Return every valid expression.
  2. Convert a binary search tree into a sorted doubly linked list Given the root of a binary search tree, rearrange the existing nodes in place to form a sorted, non-circular doubly linked list. Use each node's left pointer as prev and right pointer as next . The head of the list should be the smallest value. Follow-up: given the head of the resulting sorted doubly linked list, insert a new node while keeping the list sorted.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Pinterest•More Machine Learning Engineer•Pinterest Machine Learning Engineer•Pinterest Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
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.