n witnesses. Each one is either **honest**, meaning they always tell the truth, or **dishonest**, meaning they may tell the truth or lie.
The witnesses have spoken about one another. You are given an n × n matrix claims:
- claims[i][j] = 1 means witness i says j is honest;
- claims[i][j] = 0 means witness i says j is dishonest;
- claims[i][j] = 2 means witness i said nothing about j.
Nobody speaks about themselves: claims[i][i] = 2.
Return the largest number of witnesses that can be honest without contradicting what the honest ones said.claims=[[2, 1, 0], [2, 2, 2], [2, 2, 2]] → 2
All three cannot be honest, since 0 would then be truthfully calling 2 a liar. If 0 is honest, 0 and 1 can be honest; if not, 1 and 2 can. Three is impossible, so the answer is 2.
claims=[[2, 0], [0, 2]] → 1
Each one calls the other a liar, so they cannot both be honest, but either one alone can.
claims=[[2, 2], [2, 2]] → 2
claims=[[2, 1, 0], [2, 2, 2], [2, 2, 2]]
2
Run checks the first 3 tests in your browser. Submit checks all 74 tests on the server, hidden ones included.