Comments

The first guy must be really suffering :(

I don't know which problem you are referring to, but I see that you are passing the parameter vector<vector<int>> nums by value instead of by reference in your solve function. This means that every time you make a call to that function, the whole structure is copied, value by value. To solve this, just put an & after the type, like this: vector<vector<int>>& nums, and see if that gets AC.

Here's a webpage that talks about passing by reference, in case you want to know more about it. It's really important.

On LIFE_GOES_ONDownvote but tell, 6 years ago
+7

I actually was in the same situation like half an year ago, and competing wasn't being fun for me anymore. But then time passed, I figured I would try again, and I'm having a blast. My problem was that I was always practicing hard problems that would take me a lot of time to solve, and so I was always frustrated.

My advice is this: whenever you find that a problem took you a lot of time to solve and it was very difficult, reward yourself by doing some easy problems. This way, you'll trick your brain to associate solving difficult problems with rewarding yourself, and easy problems with the actual reward. Sweet endorphins all around.

Great joke man, +1 and favourited

Using your solution of Div1A, doesn't this testcase print 2 instead of 3?

4
1 2 1 3

The $$$l_i$$$ would be

1 2 1 2

and the $$$r_i$$$ would be

2 1 2 1

The only elements that satisfy $$$a_{i - 1} + 1  \lt  a_{i + 1}$$$ are the first and the last if you interpret the element before the first and after the last as $$$-\infty$$$. And for those, $$$l_{i - 1} + 1 + r_{i + 1} = 2$$$ ($$$l_{i - 1} = 0$$$ when $$$i = 1$$$, and $$$r_{i + 1} = 0$$$ when $$$i = n$$$). So the answer is 2. But there is a subsegment of length 3: we could choose the last 3 elements 2 1 3 and change the 2 to a 0, and we would have the sequence 0 1 3, which is strictly increasing.

On Um_nikRound #576 Editorial, 7 years ago
+3

No, the n is the length of the array, not the amount of different values in the array.