## Question 1 What is the output if the following arrays are given as input? nums1 = [5, 4, 7] nums2 = [4, 5, 7, 3] ### Options 1. ans = [7, 7, 3] Incorrect ---------------------------- 2. ans = [7, 7, -1] Incorrect ---------------------------- 3. ans = [7, 5, -1] Correct Since the next greater element of 5 in nums2 is 7, we'll put 7 in the first slot in the ans array. The next greater element of 4 in nums2 is 5. There is no value greater than 7 in nums2, so we'll put -1 in the last slot in the ans array. ---------------------------- 4. ans = [7, 5, 3] Incorrect ---------------------------- --------------------------------------------- ## Question 2 What is the output if the following arrays are given as input? nums1 = [9, 7, 6] nums2 = [5, 7, 6, 8, 9] ### Options 1. ans = [-1, 8, 8] Correct Since 9 is the greatest element in the nums2 array, we'll put -1 in the first slot in the ans array. The next greater element of 7 in nums2 is 8 and the next greater element of 6 in nums2 is also 8. ---------------------------- 2. ans = [-1, 9, 8] Incorrect ---------------------------- 3. ans = [6, 8, 9] Incorrect ---------------------------- 4. ans = [9, 9, 9] Incorrect ---------------------------- --------------------------------------------- ## Question 3 What is the output if the following arrays are given as input? nums1 = [25, 56, 100, 63] nums2 = [63, 25, 56, 76, 100] ### Options 1. ans = [56, 76, -1, 76] Correct The next greater element of 25 in nums2 is 56, so we'll put 56 in the first slot in the ans array. The next greater element of 56 in nums2 is 76. 100 is the largest element in nums2, so we'll put -1 in the third slot in the ans array. The next greater element of 63 in nums2 is 76. ---------------------------- 2. ans = [76, 76, 76, -1] Incorrect ---------------------------- 3. ans = [100, 76, -1, -1] Incorrect ---------------------------- 4. ans = [56, 100, 76, 100] Incorrect ---------------------------- ---------------------------------------------