Skip to content
Discussion options

You must be logged in to vote

We can use bit manipulation to track the parity (even or odd) of vowels, along with a hash table to store prefix states. Here's how it can be approached:

Steps:

  1. Bitmask Representation: Since there are five vowels (a, e, i, o, u), we can use a 5-bit integer (bitmask) to represent whether the count of each vowel is odd or even. For each character:

    • Bit 0 represents whether the count of 'a' is odd.
    • Bit 1 represents whether the count of 'e' is odd.
    • Bit 2 represents whether the count of 'i' is odd.
    • Bit 3 represents whether the count of 'o' is odd.
    • Bit 4 represents whether the count of 'u' is odd.

    For example, a bitmask 00110 means i and o appear an odd number of times, while a, e, and u app…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mah-shamim
Comment options

mah-shamim Sep 15, 2024
Maintainer Author

@basharul-siddike
Comment options

Answer selected by mah-shamim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants