My issue
n = int(input())
l = list(map(int, input().split(" ")))
strength_diff = 0
for i in range(n):
for j in range(n):
if i != j:
strength_diff += abs(l[i] - l[j])
print(strength_diff//2)
What is the issue in this code…
Sample input is cleared but not other inputs.
My code
# cook your dish here
n = int(input())
l = list(map(int, input().split(" ")))
strength_diff = 0
for i in range(n):
for j in range(n):
if i != j:
strength_diff += abs(l[i] - l[j])
print(strength_diff//2)
Problem Link: CodeChef: Practical coding for everyone