ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
// 1 Approachclass Solution { public: vector removeDuplicate(vector& arr) { // code here // Freq stored vector freq(101,0); vector ans; for(int i=0;i
// 2nd Approachclass Solution { public: vector removeDuplicate(vector& arr) { // code here unordered_map map; vector ans; for(int i:arr){ if(map[i] ==0){ ans.push_back(i); map[i] = 1; } } return ans; }};
// 3rd Approachclass Solution { public: vector removeDuplicate(vector& arr) { // code here unordered_set set; vector ans; for(int i:arr){ if(set.find(i) == set.end()){ ans.push_back(i); } set.insert(i); } return ans; }};
// 1 Approach
class Solution {
public:
vector removeDuplicate(vector& arr) {
// code here
// Freq stored
vector freq(101,0);
vector ans;
for(int i=0;i
// 2nd Approach
class Solution {
public:
vector removeDuplicate(vector& arr) {
// code here
unordered_map map;
vector ans;
for(int i:arr){
if(map[i] ==0){
ans.push_back(i);
map[i] = 1;
}
}
return ans;
}
};
// 3rd Approach
class Solution {
public:
vector removeDuplicate(vector& arr) {
// code here
unordered_set set;
vector ans;
for(int i:arr){
if(set.find(i) == set.end()){
ans.push_back(i);
}
set.insert(i);
}
return ans;
}
};