Company: Amazon_29may

Difficulty: medium

Problem Statement

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 A university department offers n courses, and the i th course has a difficulty rating stored in difficulty[i] . An administrator can build a "course structure" by deleting exactly one contiguous, non-empty run of courses from the original list — in other words, one subarray. Call the result "well-organized" whenever the courses left over after that deletion form a non-empty list whose difficulty ratings are sorted from smallest to largest. Given the array difficulty , count how many distinct "well-organized" course structures can be produced this way. Examples Example 1 Input: difficulty = [1, 2, 1, 2] Output: 3 Explanation: The following deletions each leave a well-organized structure behind: Deleti

More Amazon_29may OA questionsInterview experiences