PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Return Top K Open Businesses

Last updated: May 19, 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

  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
  • Implement SFT Sample Packing - Microsoft (medium)
  • Implement SQL Table and DNA Ordering - Microsoft (medium)
Microsoft logo
Microsoft
May 10, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0

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.

Comments (0)

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