├── Check if Every Row and Column Contains All Elements(CPP) └── Sum of Upper and Lower Triangles(CPP) /Check if Every Row and Column Contains All Elements(CPP): -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool checkValid(vector>& matrix) { 4 | int a=matrix.size(); 5 | int b=matrix[0].size(); 6 | for(int i=0;imp; 8 | for(int j=0;jmp; 19 | for(int i=0;i 2 | using namespace std; 3 | class Solution 4 | { 5 | public: 6 | vector sumTriangles(const vector >& matrix, int n) 7 | { 8 | vector a; 9 | int d=0; 10 | int e=0; 11 | int f=0; 12 | for(int i=0;ij){ 21 | f+=matrix[i][j]; 22 | } 23 | } 24 | }a.push_back(d+e); 25 | a.push_back(d+f); 26 | return a; 27 | } 28 | }; 29 | int main() { 30 | int t; 31 | cin>>t; 32 | while(t--) 33 | { 34 | int n; 35 | cin>>n; 36 | vector > matrix(n); for(int i=0; i>matrix[i][j]; 42 | } 43 | Solution ob; 44 | vector result = ob.sumTriangles (matrix,n); 45 | for (int i = 0; i < result.size(); ++i){ 46 | cout<