jeudi 9 novembre 2023

Don't understand somethings in C++

class Rotations
{
public:
        static bool containAllRots(const std::string &strng, std::vector<std::string> &arr)
        {

            if (strng == "")
                return true;

            std::string value = strng;

            for (size_t i = 0; i < strng.length(); i++)
            {
                std::rotate(value.begin(), value.begin() + 1, value.end());

                if (std::find(arr.begin(), arr.end(), value) == arr.end())
                    return false;
            }

                 return true;
        }
};

1- Why was another variable declared as value instead of using a string directly? Why does an error occur when I use a string directly?

2- What exactly does this line in the code mean? std::find(arr.begin(), arr.end(), value) == arr.end()

Aucun commentaire:

Enregistrer un commentaire