You are given process logs in arrival order. Treat each log as a full string entry.
Return the first log entry that appears exactly once in the entire sequence. If no such log exists, return an empty string.
Complete the function findFirstUniqueLog in the editor below.
findFirstUniqueLog has the following parameter:
String[] logs: the process logs in arrival order
Returns
String: the first log whose final frequency is exactly one, or "" if none exists.
Examples
01 · Example 1
logs = ["A", "B", "A", "C", "B"] return = "C"
A and B each appear twice. C is the first log whose total frequency is exactly one.
02 · Example 2
logs = ["x", "y", "x", "y"] return = ""
Every log appears more than once, so there is no unique entry.
Constraints
1 <= logs.length <= 10^6- Each log entry is treated as an entire string and may contain spaces.
- The answer is based on the original order among log entries whose final count is exactly one.
More Uber problems
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026
- Maximal Square AreaONSITE INTERVIEW · Seen May 2026
- First Unique IP Hitting the ServerPHONE SCREEN · Seen May 2026
- Jump Game with Prime-Step RuleOA · Seen May 2026
public String findFirstUniqueLog(String[] logs) {
// write your code here
}
logs["A", "B", "A", "C", "B"]
expected"C"
sign in to submit