CT30393

The Moonlit shelves of Sarla

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Sarla runs the lighthouse at the cork grove of Barkhaven. Today the books show a list of shelves, and the numbers must be worked out before sundown. Task: Print the minimum absolute difference between any two array elements. Input format: First line: n (>=2). Second line: n integers. Output format: Print the minimum pairwise absolute difference. Constraints: 2 <= n <= 5645; -1000000 <= a[i] <= 1000.

Example 1:

Input: 3398 -247041 -160854 -527466 283 -152384 -415051 -468608 -687111 -792825 -693832 -909688 -789454 -10057 -352198 -548255 -698419 -119544 -312198 -866899 -5155 -939355 -990685 -850673 -133230 -336260 -763679 -746529 -187044 -379933 -988259 -209154 -582795 -278423 -898724 -659319 -663543 -865973 -890322 -510037 -662425 -350653 -624238 -215731 -258560 -400959 -277169 -392698 -261707 -411455 -798777 -388907 -625319 -816512 -199976 -753326 -141022 -286602 -713831 -509442 -579386 -934049 -405063 -476552 -492619 -405805 -32715 -727158 -925687 -434641 -436648 -804822 -959252 -454553 -85498 -195569 -605617 -702724 -732422 -513593 -701175 -995914 -367621 -435022 -648889 -639191 -519743 -513214 -121527 -997368 -893957 -675691 -827756 -117564 -875569 -283945 -624286 -763246 -189028 -276578 -815596 -501…
Output: 0

Example 2:

Input: 3200 -871173 -420670 -720183 -634946 -94752 -54101 -464187 -115509 -269060 -358035 -242699 -610485 -60390 -758774 -889089 -850870 -620800 -892289 -562421 -559896 -898858 -559388 -329890 -389802 -634225 -689215 -165185 -719599 -502820 -977385 -745296 -557899 -701098 -47988 -848521 -405787 -262678 -119385 -226922 -138002 -504142 -675635 -452666 -255300 -255730 -463146 -900949 -505990 -988945 -158225 -519606 -398651 -577473 -484235 -538598 -585291 -502620 -900049 -861910 -194508 -650255 -160337 -436026 -667693 -922205 -983536 -712875 -319777 -345318 -240316 -731651 -572090 -26753 -441631 -777424 -719454 -41297 -537359 -76390 -886774 -300313 -426963 -321647 -407674 -3643 -790599 -199727 -224285 -332237 -446677 -457801 -184573 -311790 -120341 -917077 -438533 -735272 -826178 -172454 -265048 -147…
Output: 0

Example 3:

Input: 732 -184683 -8451 -83608 -949547 -650676 -203041 -16225 -20652 -458256 -770153 -954507 -298298 -891929 -361203 -618015 -771472 -500735 -555796 -193960 -549202 -738395 -549171 -373192 -727184 -769977 -647373 -165848 -325620 -193614 -487827 -660899 -863332 -587263 -535373 -779439 -109373 -804372 -282234 -639429 -795214 -20842 -784133 -214789 -558808 -572484 -712822 -40691 -389906 -48107 -221013 -139118 -657368 -970771 -121252 -511248 -217866 -501796 -375853 -747678 -553380 -789598 -928398 -646303 -236959 -815929 -728473 -936465 -234763 -848980 -607157 -80598 -950042 -977189 -847990 -484296 -617831 -18280 -812676 -3916 -924520 -294680 -97562 -513434 -417031 -71108 -824814 -110472 -150709 -987377 -266882 -78659 -609911 -383182 -830957 -690341 -125423 -376606 -908522 -218399 -655463 -868567 -82…
Output: 4

Constraints:

2 <= n <= 5645; -1000000 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
The Moonlit shelves of Sarla - MEDIUM Coding Problem | CodeTikki