Solve in Python:
“Jesse, you asked me if I was in the meth business, or the money business… Neither. I’m in the empire business.”
Walter’s sold his stack in Gray Matter Technologies, a company which he deserved half a credit, for peanuts. Now this company is worth a billion dollar company. Walter wants to get it's shares to have his Empire Business back and he founds an opportunity.
There are $N$ persons having shares $A_1, A_2, A_3, … A_N$ in this company. Walter can buy these shares with their minimum Sold Values.
Sold Values of a person's share $ i $ $(1 \leq i \leq N) $ with another person's share $ j $ $ (1 \leq j \leq N) $ is equal to $ A_j+|i-j| $. So, a person's share can have $ N $ possible sold values and Walter has to find minimum sold value among them for each person.
Since Walter has to run his meth business also he asks you to find minimum sold value for each person.

-----Input:-----
- First line will contain $T$, number of test cases. Then the testcases follow.
- The First line of each test case contains a integer $N$.
- The Second line of each test case contains $N$ space integers namely $A_1,A_2,…A_N$.

-----Output:-----
For each test case, output in single line $N$ space integers denoting minimum sold value for each person.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 2*10^6 $
- $1 \leq A_i \leq 10^9 $
Sum of $N$ over all test cases will not exceed $2*10^6$.

-----Sample Input:-----
2
5
6 5 5 5 2
5
1 2 3 4 5

-----Sample Output:-----
6 5 4 3 2
1 2 3 4 5

-----Explanation-----
For first case:
- Sold value for index $1$:  $6,6,7,8,6$
- Sold value for index $2$:  $7,5,6,7,5$
- Sold value for index $3$:  $8,6,5,6,4$
- Sold value for index $4$:  $9,7,6,5,3$
- Sold value for index $5$:  $10,8,7,6,2$
Minimum sold value for each index will be $6,5,4,3,2$.

T = int(input())
for _ in range(T):
 N = int(input())
 A = list(map(int, input().split()))
 Llist = [A[0]]
 Rlist = [A[N-1]]
 for i in range(1, N):
  Llist.append(min(Llist[-1]+1, A[i]))
  Rlist.append(min(Rlist[-1]+1, A[N-1-i]))
 print(*[min(Llist[i], Rlist[N-1-i]) for i in range(N)])


Solve in Python:
⚠ The world is in quarantine! There is a new pandemia that struggles mankind. Each continent is isolated from each other but infected people have spread before the warning. ⚠

🗺 You would be given a map of the world in a type of string:

    string s = "01000000X000X011X0X"

    '0' : uninfected

    '1' : infected

    'X' : ocean

⚫ The virus can't spread in the other side of the ocean.

⚫ If one person is infected every person in this continent gets infected too.

⚫ Your task is to find the percentage of human population that got infected in the end.

☑ Return the percentage % of the total population that got infected.

❗❗ The first and the last continent are not connected!

💡 Example:

     start: map1 = "01000000X000X011X0X"
     end:   map1 = "11111111X000X111X0X"
     total = 15
     infected = 11
     percentage = 100*11/15 = 73.33333333333333

➕ For maps without oceans "X" the whole world is connected.

➕ For maps without "0" and "1" return 0 as there is no population.

def infected(s):
    total_population = s.split('X')
    total = 0
    infected = 0
    for population in total_population:
        if "1" in population:
            infected += len(population)
        total += len(population)

    try:
        return (100 * infected) / total
    except ZeroDivisionError:
        return 0