Company: Amazon_29may
Difficulty: medium
Course Structure Analysis body { font-family: Arial, sans-serif; line-height: 1.6; margin: 20px; } pre { background-color: #f4f4f4; padding: 10px; border: 1px solid #ddd; overflow-x: auto; } .code-highlight { color: darkblue; font-weight: bold; } Course Structure Analysis Problem Statement The department of mathematics has n courses. The difficulty of the i th course is represented by the array difficulty[i] . A "course structure" can be created by removing a non-empty subarray from the original array of course difficulties. A subarray is defined as a contiguous segment of the array. A "well-organized" course structure is one where the remaining courses (after removing the subarray) are non-empty and sorted in increasing order of difficulty. Given the array difficulty , your task is to find the number of "well-organized" course structures that can be created. Examples Example 1 Input: difficulty = [1, 2, 1, 2] Output: 3 Explanation: The well-organized course structures are obtained by