You are viewing a single comment's thread. Return to all comments →
For Test Case 1 this is good solution:
for(i=14;i
if(input[i-1] !== " " &&input[i] !== " " && input[i+1] !== " "){ arr.push(" "); arr.push("0"); } } } for(i=0;i<arr.length;i++){ if(arr[i] !== " "){ arr2.push(arr[i]); } } //console.log(arr2); for(i=0;i<arr2.length-1;i+=2){ //console.log(i); if(arr2[i] > arr2[i+1]){ if(out !== "YES"){ out = "YES"; //console.log(i+": "+arr[i]+" "+arr[i+1]+" "+out); console.log(out); } }else if(arr2[i+1] == 0){ if(out !== "NO"){ out = "NO"; //console.log(i+": "+arr[i]+" "+arr[i+1]+" "+out); console.log(out); } }else if(arr2[i] == 3 && arr2[i] - arr2[i+1] < -2){ if(out !== "INVALID"){ out = "INVALID"; //console.log(i+": "+arr[i]+" "+arr[i+1]+" "+out); console.log(out); } }else if(arr2[i] < arr2[i+1]){ if(out !== "NO"){ out = "NO"; //console.log(i+": "+arr[i]+" "+arr[i+1]+" "+out); console.log(out); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Move the Coins
You are viewing a single comment's thread. Return to all comments →
For Test Case 1 this is good solution:
for(i=14;i