Created
February 6, 2025 21:41
-
-
Save ag8023/c8a33da6db2d0420a2a206c83ca2b0f9 to your computer and use it in GitHub Desktop.
Find missing number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int missingNumber(vector<int>& nums) { | |
set<int> st; | |
int i; | |
for(int i = 0; i < nums.size(); i++){ | |
st.insert(nums[i]); | |
} | |
for(i = 0; i < nums.size(); i++){ | |
if(st.find(i) == st.end()){ | |
break; | |
} | |
} | |
return i; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment