kucheasysa

Algoverse_adesh_28

Jun 26th, 2024
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. class Solution:
  2.     def findMissingAndRepeatedValues(self, grid: List[List[int]]) -> List[int]:
  3.        
  4.         grid1 = sorted(i for j in grid for i in j)
  5.         ans = []
  6.         grid1 = sorted(grid1)
  7.         for i in range(len(grid1)-1):
  8.             if grid1[i] == grid1[i+1]:
  9.                 ans.append(grid1[i])
  10.                 grid1.pop(i)
  11.                 break
  12.         count = 1
  13.         print(grid1)
  14.         for i in grid1:
  15.             if i != count:
  16.                 ans.append(count)
  17.                 return ans
  18.             count += 1
  19.         ans.append(grid1[-1]+1)
  20.         return ans
  21.        
  22.  
Advertisement
Add Comment
Please, Sign In to add comment