#include <iostream>
#include <cstdint>

enum class PinState: uint8_t{
    High = 1,
    Low = 0
};
const char* toString(PinState s){
    switch(s){
        case PinState::High:
            return "HIGH";
        case PinState::Low:
            return "LOW";
        default:
            return "LOW";
    }
}
// Declare enum class PinState with underlying type uint8_t
// Values: Low, High

// Implement: const char* toString(PinState s)

int main() {
    int x;
    std::cin >> x;

    // x is guaranteed to be 0 or 1
    PinState s = (x == 0) ? PinState::Low : PinState::High;
    std::cout << toString(s);
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Expected Output

LOW