Round 2: Coderpad
Directly dived in Code
2 Questions were asked ie Easy & Medium
My Interview went beyond specified time.. I took moretime to design 2nd question.. union find didn't directly strike to my mind that time.
Simple HashMap based: Parse apache log file to get most frequent logs
https://leetcode.com/discuss/interview-question/949160/goldman-sachs-phone-most-frequent-ip-address-from-the-logs
Union find algorithm: find root with max nodes in disjoint graphs specifically trees.
A forest is represented with a hashmap. This hashmap has this key -> value relationship: child -> parent.
Every node has a unique integer element. I needed to find out the largest tree's root node. If there is a tie, return the smallest root.
The tree with the highest number of nodes, is the largest one. The edges are directed from child to parent.
Input:
{{1 -> 2}, {3 -> 4}}
Output:
2
tell me limitations in my solution: I initialized array with -1 and while travering input I'll keep populting array for index of child with parent .. and keep on checking if parent of this child is already found then just put that