Close
Topic list
Total Negative Numbers In A Sorted Matrix
EASY
Matrices (2D Arrays)
Topics (Covered in this problem)
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Total Negative Numbers In A Sorted Matrix

Contributed by
Abhinav Jain
Easy
0/40
Share

## Problem Statement

#### For Example:

``````You are given ‘N’ = 3, ‘M’ = 2 and ‘MAT’= [[3, 1],[2, -1],[1, 2]]. Then the answer will be two for the first test case because there are two negative numbers in the given matrix(-1, -2).
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
3 2
3 1
2 -1
1 -2
3 3
3 2 1
0 -1 -2
-3 -4 -5
``````
##### Sample Output 1:
``````2
5
``````
##### Explanation of Sample Input 1:
``````For the first test case, the answer will be two for the first test case because there are two negative numbers in the given matrix(-1, -2).

For the second test case, the answer will be five because there are five negative numbers in the given matrix(-1, -2, -3, -4, -5).
``````
##### Sample Input 2:
``````2
2 2
3 -1
2 -1
2 2
1 1
1 1
``````
##### Sample Output 2:
``````2
0
``````
Auto
Console