PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Uber

Solve stock profit and vertical tree traversal

Last updated: Mar 29, 2026

Quick Overview

Assesses proficiency in array processing and binary tree traversal algorithms—specifically single-pass analysis of time-series data and coordinate-based vertical ordering of tree nodes; Category: Coding & Algorithms; Level of abstraction: implementation-level algorithmic coding.

  • medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Solve stock profit and vertical tree traversal

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You have a 60-minute coding interview with two algorithm questions: 1) **Max profit from one stock trade** - Input: an integer array `prices`, where `prices[i]` is the stock price on day `i`. - Task: Choose **one** day to buy and a **later** day to sell to maximize profit. Return the maximum profit; if no profitable trade is possible, return `0`. 2) **Vertical traversal of a binary tree** - Input: the root of a binary tree. - Define coordinates: root at `(row=0, col=0)`, left child `(row+1, col-1)`, right child `(row+1, col+1)`. - Task: Return the nodes grouped by vertical columns from leftmost `col` to rightmost. - Within each column, order nodes by `row` ascending (top to bottom). - If multiple nodes share the same `(row, col)`, order those nodes by their value ascending. - Output: a list of lists of node values following this ordering.

Quick Answer: Assesses proficiency in array processing and binary tree traversal algorithms—specifically single-pass analysis of time-series data and coordinate-based vertical ordering of tree nodes; Category: Coding & Algorithms; Level of abstraction: implementation-level algorithmic coding.

Related Interview Questions

  • Maximize Throughput and Count Trigger Components - Uber (medium)
  • Replace Dashes With Nearest Letters - Uber (medium)
  • Find Earliest Column With One - Uber (easy)
  • Solve Wonderful Strings and Grid Queries - Uber (hard)
  • Count Islands After Land Additions - Uber (medium)
Uber logo
Uber
Feb 9, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
9
0

You have a 60-minute coding interview with two algorithm questions:

  1. Max profit from one stock trade
  • Input: an integer array prices , where prices[i] is the stock price on day i .
  • Task: Choose one day to buy and a later day to sell to maximize profit. Return the maximum profit; if no profitable trade is possible, return 0 .
  1. Vertical traversal of a binary tree
  • Input: the root of a binary tree.
  • Define coordinates: root at (row=0, col=0) , left child (row+1, col-1) , right child (row+1, col+1) .
  • Task: Return the nodes grouped by vertical columns from leftmost col to rightmost.
    • Within each column, order nodes by row ascending (top to bottom).
    • If multiple nodes share the same (row, col) , order those nodes by their value ascending.
  • Output: a list of lists of node values following this ordering.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software 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.