Simple C++ solution


  • -1
    D

    class Solution {
    public:
    int kthSmallest(vector<vector<int>>& matrix, int k) {
    int n = matrix.size();
    vector<int> tmp = matrix[0];
    if (n > 1)
    {
    for (int i = 1; i < n; i++)
    {
    tmp.insert(tmp.end(), matrix[i].begin(), matrix[i].end());
    }
    }
    std::sort(tmp.begin(), tmp.end());
    return tmp.at(k - 1);
    }
    };


  • 0
    C
    This post is deleted!

Log in to reply
 

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