Can any one please help me with this problem, i am not able to get to an optimal solution.

# Sub-Sequence Count

**rk_221b**#1

**gagangaur**#2

first sort the array and then use sliding window to find the subarrays which satisfy the above condition and in the end add ânâ to the answer because each element individually is also satisfying the condition.

**rk_221b**#3

how will the sliding window be useful in this case as we need to check all subsequences with different lengths.

**rk_221b**#5

I had given the contest yesterday and i thought its over now and there will be no editorial so thatâs why i aksed it here.

**rk_221b**#6

There is no point in CHEATING!!! a question of a 3 hr contest on a discussion platform. I was not able to get to optimal solution thatâs why i asked it here Just to learn.

**decodex**#7

I can Totally understand your situation. (And may be i should say a sorry tooâș)

But, the contest is currently live. If, the solution is discussed, then that is going to help others during live content, which i think, should not be the case.

please, allow the contest to end.

End date : 18th Mayâ19

**rk_221b**#8

Yeah you are right if contest is live then we shouldnât discuss it ,we can discuss it after 18 and if you were able to solve the problems then we can discuss it.

**karangreat234**#10

I read the question. Figured out the correct simple approach in under a minute. Will discuss it when contest ends

**gagangaur**#11

Well i tried this and luckily it got accepted well would love to see your approach and also please do discuss rest two questions if someone had solved them they two were also really great question.

**karangreat234**#12

Ok,ok,sorry,I get it. When you said âsort the arrayâ,I assumed the solution is WAâŠthen realized that its ok to sort as guys are only talking about the first and last element.

Sorry

**gagangaur**#13

No issues man can you help me out with this problem like how to approach it that would be great if you do so

and here goes the link to the problem

see if you get this.

**karangreat234**#15

Ok,Iâve solved it. Its such a nice problem. Iâll write its editorial on Codechef discuss

**karangreat234**#17

I understood the sorting part, but after that the straightforward thing to do is binary search, may I know how/what did you do with sliding window after the contest? Thanks!

**karangreat234**#19

Yup,now,as usual, after getting all nice info about the problem, @l_returns will secretly enter that contest with his tools and weapon and destroy the competition. Beware Guyzz!!

**ratnesht23**#21

now the competition is over now can some one help us out with the problem sub sequence count