Find the K Closest Values in a Sorted Array

Read the full interview experience this question came from →

Quick Overview

Find exactly k closest values to a target in an ascending integer array, returning them in sorted order. Binary-search the left edge of the answer window, apply the smaller-value tie break, and reach O(log(n-k+1)+k) time.

Find the K Closest Values in a Sorted Array

Company: LinkedIn

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Overview: Find exactly k closest values to a target in an ascending integer array, returning them in sorted order. Binary-search the left edge of the answer window, apply the smaller-value tie break, and reach O(log(n-k+1)+k) time.

Read the full LinkedIn Software Engineer interview experience this question came from

|Home/Coding & Algorithms/LinkedIn
LinkedIn logo
LinkedIn
May 13, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
6
0
Loading...

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...