n,p=map(int,input().split())
l=list(map(int,input().split()))
t=[]
for i in range(n):
if l[i]%p==0:
t.append(i)
for i in range(len(t)-1):
q=sorted(l[t[i]+1:t[i+1]])
l=l[:t[i]+1]+q+l[t[i+1]:]
print(*l)
n,p=map(int,input().split())
l=list(map(int,input().split()))
t=[]
for i in range(n):
if l[i]%p==0:
t.append(i)
for i in range(len(t)-1):
q=sorted(l[t[i]+1:t[i+1]])
l=l[:t[i]+1]+q+l[t[i+1]:]
print(*l)
Hi friends....
In this blog I'm going to give answer for daily test skillrack program, daily challenges and kick start programs and give some coding techniques.
It'll be helpful for u sure and make it usefull
Learn More →
0 Comments