JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (oldest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
A somewhat better solution | Reply
I think that your solutions are good, but running a BFS involves a sizable time complexity. I solved the Grafix Map problem in a O(n^2) and I am working on bringing it down to an O(n). I did this by simply feeding the input into a UnionFind data structure that I wrote. I enhanced this structure with the ability to return a list of all connected points as a list of lists.
Please see this on my github website at: https://github.com/stevenlinzer/InterviewPractice and comment on it if you are interested.
Regards, ...
RSS