Update appNew update is available. Click here to update.
About
Python - Default language
My Stats
EXP gained
yellow-spark
768
Level
4 (Scholar)
Community stats
Discussions
0
Upvotes
0
Know more
12
Total problems solved
8
Easy
3
Moderate
1
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

3 days

Less

More

Discussions
Matrix Is Symmetric most easy answer and optimal also in python
Interview problems

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

profile
Shoury Verma
Published On 18-Aug-2023
57 views
0 replies
1 upvotes
Sum Of Zeroes in python with best optimal solution
Interview problems

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

profile
Shoury Verma
Published On 18-Aug-2023
81 views
0 replies
0 upvotes
First Missing Positive One of the easiest solution in Python
Interview problems

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)

profile
Shoury Verma
Published On 12-Aug-2023
103 views
1 replies
0 upvotes
Second largest element in the array one of the way
Interview problems

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

 

profile
Shoury Verma
Published On 10-Aug-2023
127 views
0 replies
0 upvotes
Rotate Array Using Numpy method #easiest_way
Interview problems

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])

profile
Shoury Verma
Published On 10-Aug-2023
97 views
0 replies
0 upvotes