## [Solution] Valleys and Hills solution codechef

Valleys and Hills solution codechef Chef built a binary string SS that has exactly NN hills and MM valleys. A hill is any index 1<i<|S|1<i<|S| such that both its neighbors are strictly smaller than it, i.e, Si−1<SiSi−1<Si and Si+1<SiSi+1<Si. A valley is any index 1<i<|S|1<i<|S| such that both its neighbors are strictly larger than it, i.e, Si−1>SiSi−1>Si and Si+1>SiSi+1>Si. Chef thinks that his string SS is the shortest among all binary strings with NN hills and MM valleys. You don’t quite …