My Number-Base-System Gap

I was stuck for a while when solving the leetcode problem Remove 9 . After sketched a relatively complicated solution, I decided to give myself a hint by reading the discussion board. It is all about numeric base conversion! When I tried to write the routine to convert a decimal number to a number in base 9, I found it …

Apply Loop Invariant in Binary Search

When reading the book “Accelerated C++” years ago, I was impressed by the effectiveness of loop invariant in ensuring bug-free of many functions implemented in the book. That reading opens me another door to formulate and solve some of the error-prone programming problems. The idea of loop invariant is a …