Mind Breaking Problems (Leetcode) - #Day7
UTF-8 Validation (I4G 10 Days Of Code Challenge)
Today's challenge in a brief summary was the most difficult and tasking challenge I have faced since the beginning of the challenge. It basically broke my will one too many times
The Challenge
Approach Strategy
On looking at the question (which I gravely underestimated), I basically came up with a simple algorithm to solve it
1. Convert the data to an octal sequence
2. Check how many bytes are in the data
3. Generate the expected digit results
4. Find the actual data results
5. Compare the results
On using this strategy, I blitzed through the example test cases and from there went on to submit....
Words cannot explain the frustration I faced with the multiple errors that came up. I realized that basically my approach was not the one they were looking for so I had to change it
Bitwise Operators
To eventually solve the problem I had to explore the concept of bit manipulation. A concept which is still foggy. But using this approach with trial and error, I was able to work with the code in a octal form and check the conditions without the results. It was basically trial and error but thankfully, It worked out. (After a day of pain and tears)