← All problemsSign in

Little Elephant and Bubble Sort

CodeChefRating 2051Open on judge ↗

Little Elephant loves bubble sorting. Bubble sorting for any array A of n integers works in the following way: var int i, j; for i from n downto 1 { for j from 1 to i-1 { if (A[j] > A[j+1]) swap(A[j], A[j+1]) } } You are given an array B of n integers. Then the array A is created using array B as following : for each i (1 ), we set Ai = Bi + d with the probability Pi, otherwise Ai = Bi. Help L

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start