First Unique Character
Read the lesson → understand the pattern → then code. Tutor works offline (built-in teacher); optional Cursor/Gemini keys upgrade chat quality.
Topic refresher: Hashing — Pay Space, Buy Time
Replace nested loops with unordered_map / unordered_set lookups.
unordered_map<int,int> mp;
for (int i = 0; i < n; i++) {
int need = target - nums[i];
if (mp.count(need)) return {mp[need], i};
mp[nums[i]] = i;
}EasyHashingLeetCode #387
First Unique Character in a String
Count frequencies, then second pass for first index with count 1.
Examples
Example 1
Input
leetcode
Output
0
Example 2
Input
loveleetcode
Output
2
Stuck? Take a nudge
C++17Autosaves