20251231

20251230

20251229

20251228

2026 is coming… :sob:

20251227

20251226

20251223-20251225

20251222

20251221

20251220

20251219

LeetCode 153. Find Minimum in Rotated Sorted Array

TODO: Clean up the conditions. I feel my current solution is messy and can be improved (maybe by consolidating if conditions)

I checked others’ solution https://github.com/garunitule/coding_practice/pull/40. I feel, my solution is acceptable (of course depending on the conversation with interviewers) under specific time limit.

class Solution:
    def findMin(self, nums: list[int]) -> int:
        # [1, 2, 3, 4, 5] -> right = middle
        # [2, 3, 4, 5, 1] -> left = middle, same as below
        # [3, 4, 5, 1, 2] -> left = middle, because arr[-1] < arr[0]
        # [4, 5, 1, 2, 3] -> left = middle
        # [5, 1, 2, 3, 4] -> right = middle
        left = 0
        right = len(nums) - 1
        while left < right:
            if right - left == 1:
                return min(nums[left], nums[right])
            middle = (left + right) // 2
            if nums[left] < nums[right]:
                if nums[left] < nums[middle] < nums[right]:
                    right = middle
                else:
                    left = middle
            else:
                if nums[middle] < min(nums[left], nums[right]):
                    right = middle
                else:
                    left = middle

        assert left == right
        return nums[left]

20251218

20251217

20251216

20251215

20251214

20251213

20251212

20251211

20251210

20251209

20251208

20251207

20251206

I feel tired and frustrated. Work is hard, and also there have been unaddressed desires.

20251205

20251204

20251203

20251202

20251201


TODO:


index 202511 202601