TODO:

20261009

I went on a date with my wife at Valley Fair Mall

#include <string>

class Solution {
public:
    int lengthOfLastWord(std::string s) {
        int i = static_cast<int>(s.size() - 1);
        while (0 <= i && s[i] == ' ') { --i; }
        int length = 0;
        while (0 <= i && s[i] != ' ') {
            --i;
            ++length;
        }
        return length;
    }
};

20261008

My wife passed all 4 exams of CPA! Congratulations! Now I’ll be a stay-at-home-husband…

20261007

20261006

I felt a little envious when someone else in my study group got a job at a Big Tech company, but on second thought, health is what matters most, and I have a lovely wife.

20261005

20261004

20261003

Today was the most relaxing day I’ve had in a while.

20261002

I ate too much in the last 3 days. will try to go back to the normal state

Today’s Stretches

Daily Reps

class Solution {
public:
    bool isPowerOfFour(int n) {
        if (n <= 0) { return false; }
        if (n == 1) { return true; }
        if (n % 4 != 0) { return false; }
        return isPowerOfFour(n / 4);
    }
};

20261001

Today’s Stretches

Daily Reps

class Solution {
public:
    bool isPowerOfTwo(int n) {
        if (n <= 0) { return false; }

        while (1 < n) {
            if (n % 2 == 1) { return false; }
            n = n / 2;  // n /= 2;
        }

        return true;
    }
};
class Solution {
public:
    bool isPowerOfTwo(int n) {
        if (n <= 0) { return false; }
        return (n & (n - 1))  == 0;
    }
};
class Solution {
public:
    bool isPowerOfFour(int n) {
        const int MASK = 0x55555555;

        if (n <= 0) { return false; }
        if ((n & MASK) != n) { return false; }
        return (n & (n - 1)) == 0;
    }
};

index 202609 202611