This problem is from https://acm.hdu.edu.cn/ I don't have the exact link to the problem though. 
I tried many approaches , either they are in efficient or way too complicated .
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | Radewoosh | 3415 |
| 8 | Um_nik | 3376 |
| 9 | maroonrk | 3361 |
| 10 | XVIII | 3345 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 162 |
| 2 | adamant | 148 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 132 |
This problem is from https://acm.hdu.edu.cn/ I don't have the exact link to the problem though. 
I tried many approaches , either they are in efficient or way too complicated .
| Name |
|---|



I don't have the exact link to the problem though. ![ ](
How come? Could you add a bigger screenshot, so it would be clear where its from — to be sure it's not ongoing contest?
My approach is also linear, but I am not sure how to explain it.my approach was to work on individual element as subarray sum need to be > 0 , to be X as majority element, so assign X as +1 and rest element will contribute -1.so we could make consecutive blocks of 0 and >0 and apply running sum , before this we have to push all identical element in vector array storing their index.
But I guess this is your question
https://dmoj.ca/problem/dmopc20c2p5/editorial
This problem's link is: https://acm.hdu.edu.cn/showproblem.php?pid=7020