PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Two Sigma

Evaluate Piecewise Linear Function

Last updated: Apr 2, 2026

Quick Overview

This question evaluates understanding of piecewise linear interpolation, numerical reasoning, and the ability to handle ordered 2D point data and edge cases such as exact-coordinate matches.

  • medium
  • Two Sigma
  • Coding & Algorithms
  • Data Scientist

Evaluate Piecewise Linear Function

Company: Two Sigma

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

Given a list of 2D points `[(x1, y1), (x2, y2), ..., (xn, yn)]`, where the points are ordered by strictly increasing `x`, connect each consecutive pair of points with a straight line segment to form a piecewise linear function. Write a function that returns the function value at a target `x`. Assumptions: - `target_x` is guaranteed to lie within the range `[x1, xn]`. - If `target_x` is exactly equal to one of the input `x` coordinates, return the corresponding `y` value. - Otherwise, find the segment that contains `target_x` and use linear interpolation to compute the result. Your function should take: - `points`: a list of `(x, y)` pairs - `target_x`: a numeric value and return: - the interpolated `y` value at `target_x`

Quick Answer: This question evaluates understanding of piecewise linear interpolation, numerical reasoning, and the ability to handle ordered 2D point data and edge cases such as exact-coordinate matches.

Related Interview Questions

  • Implement Price-Time Order Matching - Two Sigma (medium)
  • Compute Piecewise Linear Interpolation - Two Sigma (medium)
  • Implement an In-Memory Database - Two Sigma (hard)
  • Merge two sorted linked lists - Two Sigma (hard)
  • Merge Two Sorted Lists - Two Sigma (hard)
Two Sigma logo
Two Sigma
Mar 3, 2026, 12:00 AM
Data Scientist
Take-home Project
Coding & Algorithms
2
0
Loading...

Given a list of 2D points [(x1, y1), (x2, y2), ..., (xn, yn)], where the points are ordered by strictly increasing x, connect each consecutive pair of points with a straight line segment to form a piecewise linear function.

Write a function that returns the function value at a target x.

Assumptions:

  • target_x is guaranteed to lie within the range [x1, xn] .
  • If target_x is exactly equal to one of the input x coordinates, return the corresponding y value.
  • Otherwise, find the segment that contains target_x and use linear interpolation to compute the result.

Your function should take:

  • points : a list of (x, y) pairs
  • target_x : a numeric value

and return:

  • the interpolated y value at target_x

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Two Sigma•More Data Scientist•Two Sigma Data Scientist•Two Sigma Coding & Algorithms•Data Scientist 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.