how to count character in the row and column that doesn't have 'a' character | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

how to count character in the row and column that doesn't have 'a' character

for example input= bbba babb bbbb output=8 input= 12a3 1234 1234 12a3 output= 14 //note= the number that had already be counted in the row can't be counted again in the column

19th Oct 2018, 3:38 PM
Yoaraci
Yoaraci - avatar
6 Answers
20th Oct 2018, 9:19 AM
Sergey Ushakov
Sergey Ushakov - avatar
0
I'd have two matrices: the input and a boolean. Set the booleans to false. For each row and column, if there isn't an a in it, set the corresponding booleans to true. Count the trues.
19th Oct 2018, 4:11 PM
John Wells
John Wells - avatar
0
For each 'a' we need to exclude corresponding row and column. The answer is character count in the not excluded rows + in the not excluded columns - their intersection (nerow*necolumn).
19th Oct 2018, 7:17 PM
Sergey Ushakov
Sergey Ushakov - avatar
0
Your example incorrect. Second variant should out 14
20th Oct 2018, 9:22 AM
Sergey Ushakov
Sergey Ushakov - avatar
- 1
sorry, can someone give me the example code? because i still don't understand about this
20th Oct 2018, 7:58 AM
Yoaraci
Yoaraci - avatar
- 1
oh thats true hahaha... thanks for the correction
20th Oct 2018, 9:25 AM
Yoaraci
Yoaraci - avatar