Tuesday, July 4th

Single Number II

A difficult problem that illustrates solving with bit manipulation.  The difficulty arises from the stated time and space constraints, meaning sorting or hashing is out of the question.  

The only previous exposure to bit manipulation was on Single Number I.  One thread of intuition thought about XORing all array elements and compare the total to the sum, but this was not correct.  A solution found %3 of the array sum through iteration and counting of every bit through AND and shifting.


Comments

Popular posts from this blog

Wednesday, September 20th

Monday, September 11th

Tuesday, September 19th