Sublists Containing Maximum and Minimum SOLUTIONS Weekly Contest 25

Sublists Containing Maximum and Minimum SOLUTION

You are given elite of numbers nums and you can eliminate all things considered one component in the rundown. Return the most extreme number of sublists that that contain both the greatest and least components of the subsequent rundown. The appropriate response is ensured to fit in a 32-piece marked whole number. 
 
Imperatives 
 
n ≤ 100,000 where n is the length of nums 
 
Model 1 
 
Info 
 
nums = [2, 1, 5, 1, 3, 9] 
 
Yield 
 
 
Clarification 
 
On the off chance that we eliminate 9 we’d get [2, 1, 5, 1, 3] and there’s eight sublists where it contains both the maximum and the min: 
 
[1, 5] 
 
[5, 1] 
 
[1, 5, 1] 
 
[2, 1, 5] 
 
[5, 1, 3] 
 
[1, 5, 1, 3] 
 
[2, 1, 5, 1] 
 
[2, 1, 5, 1, 3] 
 
Model 2 
 
Information 
 
nums = [5, 5] 
 
Yield 
 
 
Clarification 
 
For this situation, we don’t eliminate any component. There’s three sublists which contain both the maximum and the min: [5], [5] and [5, 5].

Related

Leave a Comment

close
error: Content is protected !!