We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Probability
- Vertical Sticks
- Discussions
Vertical Sticks
Vertical Sticks
Sort by
recency
|
31 Discussions
|
Please Login in order to post a comment
The editorial has the most inefficient solution to this problem. Three for loops--are you sure? This was my linear python3 solution (I tried to make it as readable as possible and in line with the vars defined in the problem's description):
This also exercises Linearity of Expectation, but all it's doing is sorting the input array
y
then walking through it to sum upv_i
. If there's a repeating value, it'll use the first instance ofv_i
for that value (sincev_i
will continue to decrease asi
increases).Error: Garbage collector could not allocate 16384 bytes of memory for major heap section.
:/
for javascript function processData(input) { //Enter your code here var loopNum=input.split("\n")[0];
}