Current streak:
0 days
Longest streak:
3 days
Less
More
from os import *
from sys import *
from collections import *
from math import *
def isMatrixSymmetric(matrix):
row1=len(matrix)
col1= len(matrix[0])
for i in range(row1):
for j in range(col1):
if matrix[i][j] != matrix[j][i]:
return False
return True
pass
from os import *
from sys import *
from collections import *
from math import *
def coverageOfMatrix(mat):
coverage = 0
rows = len(mat)
cols = len(mat[0])
for i in range(rows):
for j in range(cols):
if mat[i][j] == 0:
if j > 0 and mat[i][j - 1] == 1:
coverage += 1
# Check right
if j < cols - 1 and mat[i][j + 1] == 1:
coverage += 1
# Check up
if i > 0 and mat[i - 1][j] == 1:
coverage += 1
# Check down
if i < rows - 1 and mat[i + 1][j] == 1:
coverage += 1
return coverage
pass
from os import *
from sys import *
from collections import *
from math import *
def firstMissing(arr, n):
p_arr = []
for x in arr:
if x > 0:
p_arr.append(x)
if(len(p_arr)==0):
return 1
else:
ele=sorted(p_arr)
for i in range(len(ele)-1):
if(i==0 and ele[0]!=1 and ele[0]!=0):
return 1
elif(ele[i+1]!=ele[i] and ele[i+1]!= ele[i]+1):
return ele[i]+1
elif(i==(len(ele)-2)):
return ele[len(ele)-1]+1
pass
# Main Code
t=int(input())
for j in range(t):
n=int(input())
arr=[int(i) for i in input().split()]
ans = firstMissing(arr,n)
print(ans)
from os import *
from sys import *
from collections import *
from math import *
from sys import stdin
import sys
def findSecondLargest(sequenceOfNumbers):
ele=set(sequenceOfNumbers)
last=sorted(ele)
if(len(last)==1):
return -1
else:
return last[len(last)-2]
pass
# Taking input using fast I/O.
def takeInput():
n = int(input())
sequenceOfNumbers = list(map(int, input().strip().split(" ")))
return sequenceOfNumbers, n
# Main.
t = int(input())
while t:
sequenceOfNumbers, n = takeInput()
print(findSecondLargest(sequenceOfNumbers))
t = t-1
from os import *
from sys import *
from collections import *
from math import *
import numpy as np
n=int(input())
arr=list(map(int,input().split()))
k=int(input())
sub_arrays = np.split(arr, [k])
print(*sub_arrays[1],*sub_arrays[0])