threeal / leetspace

A dedicated workspace and archive for my LeetCode submissions
https://leetcode.com/threeal
MIT License
1 stars 1 forks source link

Solve Problem 2135. Count Words Obtained After Adding a Letter #1362

Closed threeal closed 1 month ago

threeal commented 1 month ago

This issue suggests solving the problem 2135. Count Words Obtained After Adding a Letter.

To achieve this, since each string consists of non-repeated lowercase English characters, one can convert each string into a 32-bit integer, with each bit indicating if a character at that position exists in the string. To compare if a start word is convertible to a target word, one can use the 32-bit integer from both words to check if the character counts differ by only one character.