Answer: LG Electronics Off-Campus OA (2021) | Find the Town Judge Problem
Answer · Posted Jun 2026
Approach Maintain a trust score for every person. If a person trusts someone, decrement their score. If a person is trusted, increment their score. The judge must have a final score of n − 1. Strategy Create an array trustCount. Traverse the trust relationships. Decrease the score of the trusting person. Increase the score of the trusted person. Find the person whose score equals n - 1. Return that person; otherwise return -1. Java Code class Solution { public int ...
The full answer & interview discussion are available to premium members.
Log in Create a free account