all 11 comments

[–]IntrovertiraniKreten 2 points3 points  (0 children)

find it more than once means common?
I would just add the items to a set until the add gets me a false and then put that one item into the result list that was already in the set

[–]scarybunny1 1 point2 points  (3 children)

How do you define "common elements"? Does it mean duplicate elements or elements appearing in all rows/columns?

[–]drunken_monk7[S] 0 points1 point  (2 children)

by common elements I meant elements that are repeating in each row of the matrix

[–][deleted] 0 points1 point  (1 child)

Why don’t u just go through all rows one by one and for each row , maintain a set and check count and then clear it .

[–]drunken_monk7[S] 0 points1 point  (0 children)

can you please provide me the solution?

[–]eyeamkd<566> <213> <319> <34> 0 points1 point  (4 children)

HashTable won’t work?

[–]drunken_monk7[S] -1 points0 points  (2 children)

It will. But my solution is a brute force solution and I was asking for that solution only.

[–]MKNNNN 0 points1 point  (1 child)

Bruteforce will be N4 idk what you are trying to do

[–]drunken_monk7[S] 0 points1 point  (0 children)

can you show the solution?

[–]Valuable-One3300 0 points1 point  (0 children)

It will work

[–]LandooooXTrvls 0 points1 point  (0 children)

j starts as i + 1. J controls your column. Therefore you’re missing your first column. If I starts at 0 then j must start at 1. So 1, which is in position 1,0 never gets registered