I ran into a counterexample of [[0,0,0],[0,0,1],[0,0,0]]. The code in the video outputs 2, but it should be -1. The chessboard cannot be made if either the two row patterns or the two column patterns are not complimentary to each other. To my knowledge, adding the following code between line 11 and line 12 can work: r_pat1, r_pat2 = cnt_r[0][0], cnt_r[1][0] c_pat1, c_pat2 = cnt_c[0][0], cnt_c[1][0] if not all(r_pat1[i]^r_pat2[i] for i in range(n)): return -1 if not all(c_pat1[i]^c_pat2[i] for i in range(n)): return -1
@errnil19883 жыл бұрын
Hello Timothy ... i have been following your channel and also solved many problems with the help of your videos..could you please do videos related to Object Oriented Design Problems too..most of the videos you can find in youtube are in java ...try to do some videos for classic questions like parking lot , ticket booking system and meeting rooms
@svenvancrombrugge90733 жыл бұрын
It's impressive how you can solve all those problems so easily. I did notice the mistake with the ">2" instead of ">1" right away while you typed it, but whenever I make such a mistake I would not be able to fix it without leaving the problem be for a while and revisit it at some later point. I'd never just find the thought error that actually is still active in my mind. How do you do that? Keep going and thank you for all the educational content!
@timc34063 жыл бұрын
Well it's easy to look smart when you've seen the answer already, I guess it's just practice, there are many times where I get stuck debugging and I have to step away too