Grokking Amazon Coding Interview
Ask Author
Back to course home

0% completed

Next Greater Element II (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given a circular integer array nums, return the array containing the next greater number for each element in nums.

A next greater number of a number num is the first greater number than the current number in its traversing-order in the array, which means you could search circularly to find its next greater number. If the next greater element doesn't exist, return -1 for the particular number number.

Examples

  • Example 1:
    • Input: nums = [2, 1, 2, 4, 3]
    • Expected Output: [4, 2, 4, -1, 4]
    • Justification: For `2

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible