naive solution in python


  • 0
    X
    class Solution(object):
        def kthSmallest(self, matrix, k):
            """
            :type matrix: List[List[int]]
            :type k: int
            :rtype: int
            """
            n = len(matrix)
            s = []
            for i in range(n):
                for j in range(n):
                    s.append(matrix[i][j])
            s.sort()
            return s[k-1]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.