+ 4
Hey, guys i don't know how to implement this problem in java can u plz tell me how i can do this.. click the YouTube link
4 Answers
+ 4
here what I have done is I choose 1st column by passing 0 form the main function then I maintain list which will keep track of row and col on which I have already selected the Number then I call the isSafe function to check if I have placed any thing on the same row before and if I haven't selected any number from that row then it selects that number and add to the selected list and then it goes for selecting next col so since I am always selecting the col next to the last one by col + 1 I don't have to worry about coloumn so I only checked rows in is safe function.
so this is how I selected different rows every time.
and when 4 elements selected I just print the selected number.
I can comment my code out if you want.
+ 3
Hi Arjun, here I have have wrote code which finds all possible solution that sums up to 34.
https://code.sololearn.com/c1J116eS3bj4/?ref=app
+ 2
Tanay thank you so muchđ
+ 1
Tanay if we select number 1 and we don't have to choose the same row and col how can I do that?!?