CT22369

Kavya's Ivory Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

It is audit day at the coral atoll of Pearldeep. Kavya spreads the weights records across the table and picks up a sharp pencil. Task: The array is sorted in non-decreasing order. Print the 1-based index of the first occurrence of x, or -1 if x is absent. Input format: First line: n and x. Second line: n sorted integers. Output format: Print the 1-based index or -1. Constraints: 1 <= n <= 311; -1000000000 <= a[i],x <= 1000000000.

Example 1:

Input: 10 -309569222 -940984765 -926774290 -663383731 -403987277 -367942972 -309569222 16439932 422104147 489944944 640123421
Output: 6

Example 2:

Input: 188 504973355 -995024234 -980050750 -967035490 -961518152 -915205041 -890989519 -886485877 -883669384 -845935773 -843746225 -843190832 -825048228 -822911781 -817137312 -791020502 -789434327 -785783259 -772657850 -764371912 -759705156 -754276660 -753677728 -743632707 -739753418 -734992470 -734604312 -731245892 -684811614 -648945000 -626388312 -625663048 -611832352 -603736224 -598337100 -578012071 -575288761 -563118335 -555797503 -553372405 -551667447 -547611122 -541570856 -519732766 -517767692 -503358551 -485994193 -475907184 -470074954 -467631819 -450232273 -441567788 -428512890 -424636384 -392877595 -387173889 -383446401 -381609562 -373262590 -370014000 -360531710 -352823013 -350966235 -348031161 -333461278 -293937010 -274576569 -253039029 -243280038 -208743991 -203128858 -196202320 -1958…
Output: -1

Example 3:

Input: 23 632797577 -954746106 -939671309 -787168640 -676265983 -674316816 -628303784 -476016849 -433564441 -379932946 -279751012 -253592675 -194284936 -112517747 -70332151 67511548 214812479 292492647 325841222 519555694 640742991 784005861 888928098 998248921
Output: -1

Constraints:

1 <= n <= 311; -1000000000 <= a[i],x <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Kavya's Ivory Ledger - EASY Coding Problem | CodeTikki