Help me in solving LOVNUM problem

My issue

help me

My code

#include <iostream>
#include <string>
using namespace std;

bool isLovely(const string &num) {
    string mirrored = ""; // String to hold the mirrored version
    for (char digit : num) {
        switch (digit) {
            case '0':
            case '1':
            case '8':
                mirrored += digit; // These digits remain the same
                break;
            case '6':
                mirrored += '9'; // 6 becomes 9
                break;
            case '9':
                mirrored += '6'; // 9 becomes 6
                break;
            default:
                return false; // Any other digit means it's not lovely
        }
    }
    // Compare the mirrored version with the original number
    return mirrored == string(num.rbegin(), num.rend());
}

int main() {
    int T;
    cin >> T; // Number of test cases
    while (T--) {
        string N;
        cin >> N; // Read the number as a string
        cout << (isLovely(N) ? "LOVELY" : "NOT LOVELY") << endl;
    }
    return 0;
}

Problem Link: Lovely Numbers Practice Coding Problem

include
include
using namespace std;

bool isLovely(const string &num) {
int left = 0;
int right = num.size() - 1;

while (left <= right) {
    char leftChar = num[left];
    char rightChar = num[right];
    
    // Check valid mirrored pairs
    if ((leftChar == '0' && rightChar == '0') ||
        (leftChar == '1' && rightChar == '1') ||
        (leftChar == '8' && rightChar == '8') ||
        (leftChar == '6' && rightChar == '9') ||
        (leftChar == '9' && rightChar == '6')) {
        left++;
        right--;
    } else {
        return false; // Not a lovely number if any pair is invalid
    }
}
return true; // All pairs matched correctly

}

int main() {
int T;
cin >> T; // Number of test cases
while (T–) {
string N;
cin >> N; // Read the number as a string
cout << (isLovely(N) ? “LOVELY” : “NOT LOVELY”) << endl;
}
return 0;
}