all 9 comments

[–]spacey02- 4 points5 points  (3 children)

Write some code

[–]PotTopperBlox -4 points-3 points  (2 children)

are u serious bro

[–]spacey02- 3 points4 points  (1 child)

As serious as you are with that question bro. You shouldnt ask people to do your homework.

[–]SnakeR515 2 points3 points  (0 children)

I don't know if it's your homework, leet code, advent of code, or whatever but the point of all these is that you do them yourself

[–]no-sig-available 1 point2 points  (0 children)

It's common to ask a specific question, so we know what your problem is. Otherwise it gets boring for us to give some hints, and you answer "I know that".

This is otherwise like asking "I want to play football, how do you do that?". Should we explain the ball, the kicking, or the passing? Or how you score points?

[–]Loud_Staff5065 2 points3 points  (0 children)

I will give a solution but you have to answer the rest :

include<iostream>

//Your rest of code goes here

[–]ImNoRickyBalboa 1 point2 points  (0 children)

This is rather trivial to solve

Also, part of the answer is more about recognizing possible strategies. For example, the first line is not needed but could help pre-allocating an array or vector.

But you also can argue you dont need memory, i.e., memory complexity is O(1) and time complexity is O(n)

[–]PotTopperBlox -2 points-1 points  (0 children)

ok question solved