← First Unique Character
Discussions
Sign in to join the discussion.
K
kgoud
OFFICIAL
2 weeks ago
Why does my solution TLE on the last test case?
Use a hash map from value to index (or count). For each element check whether its complement is already in the map, then insert it. That makes it O(n) instead of the O(n²) brute force.
💬 1 reply
J
jahnavisub6
1 month ago
Asked in my Salesforce OA last week.
Use a hash map from value to index (or count). For each element check whether its complement is already in the map, then insert it. That makes it O(n) instead of the O(n²) brute force.
💬 3 replies
K
krishnahegde
2 months ago
Intuition + complexity breakdown for First Unique Character.
Use a hash map from value to index (or count). For each element check whether its complement is already in the map, then insert it. That makes it O(n) instead of the O(n²) brute force.
💬 1 reply
K
kavyanaidu
2 months, 3 weeks ago
Intuition + complexity breakdown for First Unique Character.
Use a hash map from value to index (or count). For each element check whether its complement is already in the map, then insert it. That makes it O(n) instead of the O(n²) brute force.
💬 1 reply