260409
260409

260409

  • AutoBuilder

Cursor is incredibly good harness.

Opus is also not Oputhetic anymore

Backlinks (0)

No backlinks found.

Debian Setup
Debian Setup

Debian Setup

sudo apt update && sudo apt install git && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && echo >> ~/.bashrc && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" && sudo apt-get install build-essential && brew install gcc btop
Backlinks (1)
  • 260415
260415
260415

260415

  • Debian Setup
  • AutoBuilder
Backlinks (0)

No backlinks found.

0704 Binary Search
0704 Binary Search

0704 Binary Search

Solved at: 220904

Question

Given an array of integers nums sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

You must write an algorithm with O(log n) runtime complexity.

Solution

python
class Solution:    def _search(self, nums: List[int], target:int, start:int, end:int) -> int:        mid = (end + start) // 2        # print(start, end, target, mid, nums[mid])        if nums[mid] == target:            return mid        elif nums[mid] != target and end <= start:            return -1        elif nums[mid] > target:            return self._search(nums, target, start, mid-1)        elif nums[mid] < target:            return self._search(nums, target, mid+1, end)        else:            return -1
    def search(self, nums: List[int], target: int) -> int:        return self._search(nums, target, 0, len(nums)-1)
  • Binary Search

Results

Runtime

  • 542 ms, faster than 6.00% of Python3 online submissions for Binary Search.

Memory Usage

  • 15.5 MB, less than 73.17% of Python3 online submissions for Binary Search.

Complexity Analysis

Time

O(n)O(n)O(n)

Space

O(1)O(1)O(1)

Backlinks (2)
  • 220905
  • Coding Tests
Index
cho.sh
I prefer CLIBB9A08260619260619컴퓨트로늄37A88F컴퓨트로늄0CF03F컴퓨트로늄2C60FB260618260618260418260418260528260528AutoBuilder63849A260419260419Setup9AC296StellaD226F7260415260415Debian SetupD2F701260414260414anaclumos/configs/AGENTS.mdED86A3Ramp의 AX (회사를 AI로 물들이는 법)840774260413260413How to get your company AI pilled46544C260411260411260409260409260407260407260406260406Separating Claude Code Personal Sub and Claude Code Company Sub33A53C
sudo apt update && sudo apt install git && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && echo >> ~/.bashrc && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" && sudo apt-get install build-essential && brew install gcc btop
Warning
This post is more than a year old. Information may be outdated.
class Solution:    def _search(self, nums: List[int], target:int, start:int, end:int) -> int:        mid = (end + start) // 2        # print(start, end, target, mid, nums[mid])        if nums[mid] == target:            return mid        elif nums[mid] != target and end <= start:            return -1        elif nums[mid] > target:            return self._search(nums, target, start, mid-1)        elif nums[mid] < target:            return self._search(nums, target, mid+1, end)        else:            return -1
    def search(self, nums: List[int], target: int) -> int:        return self._search(nums, target, 0, len(nums)-1)