CT29520

The Insertion Slot at Tidewater

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the coastal hub of Tidewater as Bhavi unrolls the day's manifest of crates. The tally will decide the next shipment. Task: The array is sorted non-decreasing. Print the 1-based position where x would be inserted to keep the order (before equal values). Input format: First line: n and x. Second line: n sorted integers. Output format: Print the insertion position (1..n+1). Constraints: 1 <= n <= 6460; -1000000 <= a[i],x <= 1000.

Example 1:

Input: 1342 -175401 -999768 -999333 -998754 -997404 -997018 -996909 -996660 -994965 -994311 -993684 -993425 -991046 -990529 -990171 -989657 -989573 -987515 -987293 -986874 -986657 -986562 -986417 -985867 -985701 -984747 -983622 -983440 -983199 -982823 -981810 -981333 -979919 -977668 -976892 -976390 -976095 -975108 -971534 -969799 -969297 -969024 -967618 -967082 -966722 -966673 -965231 -964993 -964805 -964584 -964463 -963601 -963475 -961965 -960420 -960060 -959496 -957877 -957789 -957600 -956899 -956318 -956073 -955831 -954849 -954515 -954353 -954191 -953551 -953285 -953002 -951797 -951741 -951626 -951480 -951345 -951238 -951121 -950946 -949899 -949749 -949714 -948522 -947711 -947643 -947513 -946341 -945487 -944123 -943900 -943697 -943296 -943118 -941615 -941174 -939403 -938893 -938606 -937234 -93…
Output: 1112

Example 2:

Input: 6353 -132311 -999944 -999936 -999736 -999677 -999674 -999474 -999454 -999248 -999166 -999135 -999135 -999005 -998837 -998775 -998770 -998686 -998650 -998640 -998628 -998565 -998431 -998283 -998104 -997958 -997853 -997802 -997775 -997756 -997747 -997711 -997605 -997593 -997583 -996996 -996983 -996784 -996676 -996641 -996605 -996604 -996504 -996315 -996063 -995681 -995671 -995643 -995487 -994351 -994069 -993501 -993306 -993217 -993154 -992938 -992729 -992326 -992287 -992115 -991836 -991715 -991431 -991329 -991084 -991006 -990623 -990374 -990322 -990291 -989905 -989846 -989819 -989705 -989616 -989579 -989252 -989142 -989131 -988908 -988869 -988798 -988751 -988519 -988436 -988162 -988111 -987839 -987735 -987729 -987347 -987307 -987152 -987032 -986780 -986053 -985616 -985604 -985575 -985354 -98…
Output: 5516

Example 3:

Input: 3896 -365519 -999155 -999116 -998729 -998673 -998544 -998232 -997903 -997896 -997112 -997006 -996386 -996300 -996248 -995966 -995905 -995883 -995791 -995473 -995293 -995137 -994908 -994817 -993884 -993699 -993539 -993115 -992825 -992425 -992414 -992345 -991717 -991428 -991426 -990786 -990214 -990044 -989516 -989426 -989087 -988992 -988844 -988395 -987967 -987474 -987470 -987042 -986844 -986820 -986677 -986582 -986443 -986436 -986346 -986209 -986114 -985617 -985572 -985569 -985101 -984800 -984484 -984220 -984142 -983800 -983625 -983421 -983050 -982492 -981835 -981740 -981512 -981333 -981237 -980951 -980935 -980846 -980547 -980337 -979844 -979609 -979453 -979343 -979285 -978989 -978853 -978506 -978309 -978218 -978000 -977805 -977780 -977544 -976999 -976682 -975350 -975120 -975032 -974468 -97…
Output: 2469

Constraints:

1 <= n <= 6460; -1000000 <= a[i],x <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
The Insertion Slot at Tidewater - MEDIUM Coding Problem | CodeTikki