Python Matrix Search Element using Different Approach || Python
In this we are going to see a basic program of pyhton matrix search element using different approach in Python Programming Language.



mat =[[1,2,3],
      [4,5,6],
      [7,8,9]]

k=7
n=3
i=0
j=n-1
flag=0

while (i < n and j >= 0):
      if mat[i][j]==k:
            print(f"Element found at {i+1},{j+1} position")
            flag+=1
            break
      elif mat[i][j]<k:
            i+=1
      else:
            j-=1

if flag==0:
    print("Element NOT found!!")

# Coded by Saahil


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post