✅✅Binary Search Solution || Single Set || No hash map || Unique Approach ☢
Intuition & Approach\n Describe your first thoughts on how to solve this problem. \nIn this problem I have used Binary search and simple unordered set to solve 
# Intuition & Approach\n<!-- Describe your first thoughts on how to solve this problem. -->\nIn this problem I have used Binary search and simple unordered set to solve the problem.\n\nThe problem wants us to find the minimum index such that atleast one of the row or column of the matrix is colored. \n\nIn my solution I have represented a colored cell using -1.\n\nInitially I have assumed that the index is at the middle of the array as we do in a binary search.\n\nFor that index = mid, I have put all the elements of array from 0 to mid in a set and called a function "color" which would color a cell if a the value present in the cell is also present in the set. Color would also check if any row or column is fully colored or not, as soon as a row or column is colored, it returns a true value else it returns false.\n\nNow, the main idea is, if at index == mid, atleast one cell is colored then the minimum value of the index for which atleast one cell is colored can only be towards the left of the mid.\n\nSo, now we store mid in our answer and check the left portion of the array like binary search does and update our answer as we go. \n\n\n# Complexity\n- Time complexity: $$O(log(n)*N*M)$$\n- where n is size of array, N is no. of rows of matrix, M is no. of columns in matrix.\n\n# Code\n```\nclass Solution {\npublic:\n    using vvi = vector<vector<int>>;\n\n    bool color(vvi mat, const unordered_set<int>& nums) {\n        bool isColor = true;\n        for (int i = 0; i < mat.size(); i++) {\n            for (int j = 0; j < mat[0].size(); j++) {\n                if (nums.count(mat[i][j])) {\n                    mat[i][j] = -1;\n                } else {\n                    isColor = false;\n                }\n            }\n            if (isColor) return true;\n            isColor = true;  // Reset for next row\n        }\n        \n        for (int j = 0; j < mat[0].size(); j++) {\n            bool isColor = true;\n            for (int i = 0; i < mat.size(); i++) {\n                if (mat[i][j] != -1) {\n                    isColor = false;\n                    break;\n                }\n            }\n            if (isColor) return true;\n        }\n        \n        return false;\n    }\n\n    int firstCompleteIndex(const vector<int>& arr, const vvi& mat) {\n        int left = 0;\n        int right = arr.size() - 1;\n        int ans = INT_MAX;\n\n        while (left <= right) {\n            int mid = left + (right - left) / 2;\n            unordered_set<int> nums(arr.begin(), arr.begin() + mid + 1);\n\n            if (color(mat, nums)) {\n                ans = min(ans, mid);\n                right = mid - 1;\n            } else {\n                left = mid + 1;\n            }\n\n            mid = left + (right - left) / 2;\n        }\n\n        return ans;\n    }\n};\n\n```
['Binary Search', 'Matrix', 'Ordered Set', 'C++']