PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Microsoft

Return Top K Open Businesses

Last updated: Jun 2, 2026

Quick Overview

This question evaluates a candidate's ability to perform filtering and multi-criteria ranking, requiring correct handling of an open-status filter and tie-breaking by score and distance.

  • hard
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Return Top K Open Businesses

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a list of business candidates. Each candidate has at least the following fields: - `score`: a numeric relevance score - `distance`: a numeric distance from the user - `isOpen`: a boolean indicating whether the business is currently open Write a function that returns the top `k` open businesses. Sorting requirements: 1. Higher `score` comes first. 2. If two businesses have the same `score`, the business with the smaller `distance` comes first. Return the selected businesses in the required order.

Quick Answer: This question evaluates a candidate's ability to perform filtering and multi-criteria ranking, requiring correct handling of an open-status filter and tie-breaking by score and distance.

Related Interview Questions

  • In-Memory URL Shortener: Encode and Decode - Microsoft (medium)
  • Minimum Moves on a Grid with k-Cell Jumps - Microsoft (medium)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Compute the Product of an Array Except Self - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
|Home/Coding & Algorithms/Microsoft

Return Top K Open Businesses

Microsoft logo
Microsoft
May 10, 2026, 12:00 AM
hardSoftware EngineerTechnical ScreenCoding & Algorithms
7
0
Practice Read
Loading...

You are given a list of business candidates. Each candidate has at least the following fields:

  • score : a numeric relevance score
  • distance : a numeric distance from the user
  • isOpen : a boolean indicating whether the business is currently open

Write a function that returns the top k open businesses.

Sorting requirements:

  1. Higher score comes first.
  2. If two businesses have the same score , the business with the smaller distance comes first.

Return the selected businesses in the required order.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

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