Expected Value Problem
You are given an integer $N$ and an array $A$ of size $N$, $A_1, A_2,..., A_N$. We define a process as shown below, your task is to find the expected value of $ans$ at the end of it. $1) $ Choose a random number $x$, equiprobably in range $[1, N]$. Initialize $ans = A_x, l = x, r = x.$ $2) $ Repeat the following $N - 1$ times : - define a temporary variable $b$ as follows : - If $l = 1$, s
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start