Advertisement
Kbekir

Untitled

Mar 3rd, 2021
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function minNumber(input) {
  2.     let n = Number(input[0]);
  3.     let index = 1;
  4.     let yIndex = 2;
  5.     let num1 = 0;
  6.     let num2 = 0;
  7.     let min = 0;
  8.  
  9.     for (let i = 1; i <= n; i++) {
  10.         num1 = Number(input[index]);
  11.         num2 = Number(input[yIndex]);
  12.  
  13.         if (num1 < num2) {
  14.             min = num1;
  15.             yIndex++;
  16.         } else if (num1 > num2) {
  17.             min = num2;
  18.             index++;
  19.         } else {
  20.             min = num1;
  21.             index++;
  22.         }
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.     }
  30.     if (n != 0) {
  31.         console.log(min);
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement