PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Pinterest

Decide target via subsequence plus/multiply expression

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design and implement combinatorial search and expression-evaluation logic, covering backtracking, pruning heuristics, reverse-search reasoning, correctness conditions for arithmetic operations, and handling 32-bit integer overflow when selecting subsequences and placing '+' and '*' with strict left-to-right evaluation. It is asked in the coding & algorithms domain to assess algorithmic problem-solving and complexity analysis, testing both practical implementation skills and conceptual understanding of search space pruning, time/space trade-offs, and edge-case reasoning.

  • Medium
  • Pinterest
  • Coding & Algorithms
  • Software Engineer

Decide target via subsequence plus/multiply expression

Company: Pinterest

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given a sequence of positive 32-bit integers A and an integer target, determine whether there exists a subsequence of A (preserving order, using each element at most once) and a placement of '+' and '*' operators between the chosen numbers such that, with equal precedence and strict left-to-right evaluation, the resulting value equals target. For example, for A = [1, 9, 8, 7, 10, 3, 1] and target = 25, one valid expression is 8*3+1. Implement a function that returns true/false and, if true, also returns one valid expression. Discuss: ( 1) a backtracking search that enforces left-to-right evaluation without normal operator precedence; ( 2) pruning heuristics (e.g., stop when partial value already exceeds reasonable bounds, avoid repeating equivalent states, and early termination rules); ( 3) a reverse search from the target using subtraction and division where subtraction continues only if the remainder stays >= 0 and division only when the current target is exactly divisible by the chosen number—explain correctness conditions and ordering; ( 4) time and space complexity, and worst-case behavior; ( 5) dealing with 32-bit overflow for intermediate results and other edge cases.

Quick Answer: This question evaluates a candidate's ability to design and implement combinatorial search and expression-evaluation logic, covering backtracking, pruning heuristics, reverse-search reasoning, correctness conditions for arithmetic operations, and handling 32-bit integer overflow when selecting subsequences and placing '+' and '*' with strict left-to-right evaluation. It is asked in the coding & algorithms domain to assess algorithmic problem-solving and complexity analysis, testing both practical implementation skills and conceptual understanding of search space pruning, time/space trade-offs, and edge-case reasoning.

Related Interview Questions

  • Maximize Boxes Stored Through One Entrance - Pinterest (medium)
  • Solve Multiple Coding Interview Problems - Pinterest (medium)
  • Implement a Sparse Matrix Class - Pinterest (medium)
  • Assign Pins to Shortest Columns - Pinterest (medium)
  • Design Hierarchical Permission Checks - Pinterest (medium)
Pinterest logo
Pinterest
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
9
0

Given a sequence of positive 32-bit integers A and an integer target, determine whether there exists a subsequence of A (preserving order, using each element at most once) and a placement of '+' and '' operators between the chosen numbers such that, with equal precedence and strict left-to-right evaluation, the resulting value equals target. For example, for A = [1, 9, 8, 7, 10, 3, 1] and target = 25, one valid expression is 83+1. Implement a function that returns true/false and, if true, also returns one valid expression. Discuss: (

  1. a backtracking search that enforces left-to-right evaluation without normal operator precedence; (
  2. pruning heuristics (e.g., stop when partial value already exceeds reasonable bounds, avoid repeating equivalent states, and early termination rules); (
  3. a reverse search from the target using subtraction and division where subtraction continues only if the remainder stays >= 0 and division only when the current target is exactly divisible by the chosen number—explain correctness conditions and ordering; (
  4. time and space complexity, and worst-case behavior; (
  5. dealing with 32-bit overflow for intermediate results and other edge cases.

Submit Your Answer

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 8,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.