function find_max(nums) { 2 let max_num = Number.NEGATIVE_INFINITY; // smaller than all other numbers 3 for (let num of nums) { 4 if (num > max_num) { 5 // (Fill in the missing line here) 6 } 7 } 8 return max_num; 9 }
given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. we define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).
for any given n, u = [1,2,3,...,n] and v = [2017,2018,2019,...,2017+n-1]. write a function that returns a vector that contains the following sequence: [1*2017, 2*2018, 3*2019,...,n*(2017+n-1)]. hint: you might want to create vectors u and v.