⌘K
Flycodx

Ice Cream Distribution Warehouse Finder

Ice Cream Distribution Warehouse Finder

MediumBinary Search100% accepted

Priya's ice cream shop in Delhi needs to order stock from a distribution center. Each warehouse maintains a specific temperature, and she needs to find the warehouse that maintains her required temperature.

Approach

Given an array of warehouse temperatures and a required temperature, find the warehouse with the closest matching temperature.

Input

temps=[-15, -10, -5, 0, 5], required=-7

Output

1
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