fork download
  1. #include<map>
  2. void FindMissingElements(int arr[], int n){
  3. /*Write your code here.
  4. *Don’t write main().
  5. *Don’t take input, it is passed as function argument.
  6. *Print output as specified in question.
  7. */
  8. map<int,int>m;
  9. int a = INT_MAX;
  10. int b = INT_MIN;
  11. for(int i=0;i<n;i++){
  12. a = min(a,arr[i]);
  13. b = max(a,arr[i]);
  14. m[arr[i]]++;
  15. }
  16. for(int i = a; i<b;i++){
  17.  
  18. if(m.find(i) == m.end()){
  19. cout<<i<<" ";
  20. }
  21. else{
  22. continue;
  23. }
  24. }
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void FindMissingElements(int*, int)’:
prog.cpp:8:5: error: ‘map’ was not declared in this scope
     map<int,int>m;
     ^~~
prog.cpp:8:5: note: suggested alternative:
In file included from /usr/include/c++/8/map:61,
                 from prog.cpp:1:
/usr/include/c++/8/bits/stl_map.h:100:11: note:   ‘std::map’
     class map
           ^~~
prog.cpp:8:9: error: expected primary-expression before ‘int’
     map<int,int>m;
         ^~~
prog.cpp:9:13: error: ‘INT_MAX’ was not declared in this scope
     int a = INT_MAX;
             ^~~~~~~
prog.cpp:9:13: note: ‘INT_MAX’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
prog.cpp:2:1:
+#include <climits>
 void FindMissingElements(int arr[], int n){
prog.cpp:9:13:
     int a = INT_MAX;
             ^~~~~~~
prog.cpp:10:13: error: ‘INT_MIN’ was not declared in this scope
     int b = INT_MIN;
             ^~~~~~~
prog.cpp:10:13: note: ‘INT_MIN’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
prog.cpp:12:7: error: ‘min’ was not declared in this scope
   a = min(a,arr[i]);
       ^~~
prog.cpp:12:7: note: suggested alternative:
In file included from /usr/include/c++/8/bits/stl_tree.h:63,
                 from /usr/include/c++/8/map:60,
                 from prog.cpp:1:
/usr/include/c++/8/bits/stl_algobase.h:243:5: note:   ‘std::min’
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
prog.cpp:13:13: error: ‘max’ was not declared in this scope
         b = max(a,arr[i]);
             ^~~
prog.cpp:13:13: note: suggested alternative:
In file included from /usr/include/c++/8/bits/stl_tree.h:63,
                 from /usr/include/c++/8/map:60,
                 from prog.cpp:1:
/usr/include/c++/8/bits/stl_algobase.h:265:5: note:   ‘std::max’
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
prog.cpp:14:9: error: ‘m’ was not declared in this scope
         m[arr[i]]++;
         ^
prog.cpp:18:12: error: ‘m’ was not declared in this scope
         if(m.find(i) == m.end()){
            ^
prog.cpp:19:13: error: ‘cout’ was not declared in this scope
             cout<<i<<" ";
             ^~~~
stdout
Standard output is empty