(100,20,3,40,550,6,77....100) So what do we do if we have a specific value (for example, index 2) that comes forward unconditionally and then in ascending order?
python
After subtracting index 2, I think we can sort the rest except index 2 and put index 2 in the front.
length = int(input()) #array length
arr = input().split() #Array input
for i in range(length):
arr[i] = int(arr[i])
n = int(input()) #Index input
tmp = arr.pop(n)
arr.sort()
arr.append(tmp)
print(arr)
© 2024 OneMinuteCode. All rights reserved.