2965: Find-Missing-and-Repeated-Values
Easy

We need to find the duplicate value and the missing value.

Code:

class Solution {
public:
    vector<int> findMissingAndRepeatedValues(vector<vector<int>>& grid) {
        int n = grid.size();
        int mp[2501] = {0};

        int sum = 0;
        int duplicate = -1;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                ++mp[grid[i][j]];
                if (mp[grid[i][j]] == 2) {
                    duplicate = grid[i][j];    
                }
                sum += grid[i][j];
            }
        }

        return {duplicate, (n*n)*(n*n+1)/2 - sum + duplicate};
    }
};

Complexity: