class Solution{ public: vector<int> twoOddNum(int Arr[], int N) { set<int>s; for(int i=0;i<N;i++) { s.insert(Arr[i]); } vector<int>v; set<int>::iterator i; for(i=s.begin();i!=s.end();i++) { v.push_back(*i); } vector<int>ans; for(int i=0;i<v.size();i++) { int count=0; for(int j=0;j<N;j++) { if(v[i]==Arr[j]) count++; } if(count%2==1) { ans.push_back(v[i]); } } sort(ans.rbegin(),ans.rend()); return ans; // code here } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter