
#SDESheetChallenge @striver_79 @takeUforward_
DAY-2
brute force - O(n^2) check all subarrays and get rejected
optimal - whenever the sum gets less than 0 make sum 0 and also before that check max condition
Buy and sell stock
brute - O(n^2) bekaar
try to sell on minimum and sell when profit is max
Sort 0s 1s and 2s
use any sorting algo would fetch us at best O(nlog n)
so we use a three pointer method which we call dutch national flag algo



English


















