Ad
  • Custom User Avatar

    n being the length of the string array, if n = 0 or k > n or k <= 0 return ""

    Where in your code do you test for that? Probably k is < 0 and you're getting a segmentation fault.

  • Custom User Avatar

    return true

    Damn, I forgot about this :\

    If you return nothing in C++, you'll instantly receive error 132, and there will be no output in the stdout. @Chrono79's snippet should work fine. There should be a return statement at the end of the function for it to compile.

  • Custom User Avatar

    You're welcome. I always thought you used the print the input part before your code, and didn't know about what FArekkusu says down below (C++ is not one of the languages I know best).

  • Custom User Avatar

    How could you not know the values if they're printed in the screen?
    Analyze that input, read the docs on the methods your function use (specially how it handles those input values) and you'll have to change it to fix it.

  • Custom User Avatar

    Sorry but i don't get it

    You were told to print input, and given a link saying how to print a vector; are you not very smart?

    #include <vector>
    
    using namespace std;
    
    class Same {
      public:
        static bool comp(vector<int> a, vector<int> b) {
          cout << "Vector 1: ";
          for (auto x : a) cout << x << " ";
          cout << "\nVector 2: ";
          for (auto x : b) cout << x << " ";
          cout << "\n";
        }
    };
    
  • Custom User Avatar
  • Custom User Avatar

    Your code is failing the 9th test, labeled Test 8 (I though it was another one), try printing the input and you'll see why, it's easy to fix. It's not related to same multiplicity and your code is ok about deleting the values.

  • Custom User Avatar

    Maybe showing your code would help.
    But, deleting elements on an array you're looping through is never a good idea, you'll be skiping values like that if you're not careful enough.

  • Custom User Avatar

    Check the input values. Read the instructions again, specially ...with the same multiplicities...