CT22754

Last registers of Varun

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the orchid house of Bloomglass, someone must schedule the next expedition. This year the task falls to Varun, armed only with the registers register. 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 <= 847; -1000000000 <= a[i],x <= 1000000000.

Example 1:

Input: 416 -118010408 -999098792 -992248159 -989948555 -984306241 -978353169 -975433709 -969407541 -965196920 -959595354 -953147640 -952060319 -952013148 -945759449 -943358798 -940622414 -938283971 -938155668 -930709358 -929811091 -923315358 -922745458 -909771587 -908297919 -906425938 -900971064 -896263280 -895229022 -893665335 -889560651 -889187415 -885963405 -884482944 -883087402 -879126742 -874242913 -874097782 -859585115 -853535707 -849553237 -846525618 -843074843 -841202541 -823615604 -821874938 -821356898 -818941606 -807233173 -805521940 -805370214 -799993251 -799966768 -797105937 -793865246 -781503554 -780966016 -779834864 -779186563 -770820427 -767972655 -767017095 -765720913 -762490356 -756428964 -755649230 -751643156 -743364432 -739132354 -732722100 -724251978 -718675440 -704417313 -685…
Output: 187

Example 2:

Input: 20 -841104886 -955402096 -874329486 -841104886 -706449925 -675635105 -551323924 -457207481 -367314945 -346211723 -309810354 -273132474 -204366046 -196848211 -177125752 -63540443 226273074 309027053 449228315 612648166 907627558
Output: 3

Example 3:

Input: 225 -297507337 -999531273 -997845587 -981669194 -979880564 -971227183 -948970237 -942007573 -930620955 -927982532 -923226514 -912927087 -894179180 -893511324 -892702975 -881508826 -877856606 -870301464 -870171228 -862835548 -860491839 -853902960 -835512110 -830990293 -814975229 -800445203 -799866744 -789692747 -777621320 -766049021 -756331842 -753045330 -720881383 -719886119 -714257251 -674469617 -674266472 -620332582 -611892113 -605330282 -584838364 -584515296 -583487956 -575536661 -563057293 -561585140 -556505932 -555018098 -550165648 -545897158 -538531084 -537565372 -522301663 -515473644 -513308801 -506572436 -497561611 -497419452 -493743276 -488813132 -486615745 -484809640 -472983313 -472909130 -470551809 -453690534 -449929272 -425124490 -411227387 -399608139 -392270095 -386471601 -384…
Output: 84

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last registers of Varun - EASY Coding Problem | CodeTikki