⌘K
Flycodx

MagicBricks Median Price Finder

MagicBricks Median Price Finder

MediumBinary Search100% accepted

Priya scrolls MagicBricks in Bangalore finding flats. Given N property prices, find minimum price point where at least M flats are available at or below that price.

Approach

Given sorted array of property prices and count M, find minimum price where count_of_properties_below_price ≥ M.

Input

prices=[30,45,60,75,90] M=3

Output

60
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3