Floor and Ceil in Sorted Array Problem

Floor and Ceil in Sorted Array Problem — ExecCode Easy DSA Practice

Solve the Floor and Ceil in Sorted Array problem on ExecCode. Free online easy DSA practice in Arrays / Binary Search. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the input needed to solve Floor and Ceil in Sorted Array. Your task is to compute the required answer and return floor and ceil, space-separated (-1 if absent). A search space contains many possible answers. In Floor and Ceil in Sorted Array, the challenge is to narrow that space intelligently instead of trying every possibility blindly. n x, then sorted nums.

Examples

Input {"nums": [1, 2, 8, 10, 12], "x": 4}; Output 2 8. Input {"nums": [1, 2, 8, 10, 12], "x": 0}; Output -1 1. Input {"nums": [1, 2, 8, 10, 12], "x": 13}; Output 12 -1

Constraints

1 <= len(nums) <= 10^5; nums sorted

Practice Floor and Ceil in Sorted Array free on ExecCode. Browse DSA problems, topic map, and placement guides.