LeetCode: 704-Binary Search 解題紀錄
題目
Given an array of integers nums
which is 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
.
Given an array of integers nums
which is 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
.
A company is planning to interview 2n
people. Given the array costs
where costs[i] = [aCosti, bCosti]
, the cost of flying the ith
person to city a
is aCosti
, and the cost of flying the ith
person to city b
is bCosti
.
今天我注意到我之前所寫的某一篇 LeetCode 解題紀錄中,居然缺乏了一部分的 Python 程式碼。我很自然地使用了題目的編號找到了該題,並從過去提交的程式碼中複製了 AC 的解答,並將其貼上我的文章,然後更新。
Read More »[已解決][WordPress] 更新時發生錯誤。無效的 JSON 回應。今天我碰到一個情況,是伺服器中所安裝的 GitLab 無法正常啟動,且透過終端機使用 sudo systemctl start gitlab-runsvdir.service
會使畫面凍結(freeze)住。
You are given an array people
where people[i]
is the weight of the ith
person, and an infinite number of boats where each boat can carry a maximum weight of limit
. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most limit
.
There is a broken calculator that has the integer startValue
on its display initially. In one operation, you can:
The numeric value of a lowercase character is defined as its position (1-indexed)
in the alphabet, so the numeric value of a
is 1
, the numeric value of b
is 2
, the numeric value of c
is 3
, and so on.
You are given a string s
. We want to partition the string into as many parts as possible so that each letter appears in at most one part.
In a row of dominoes, tops[i]
and bottoms[i]
represent the top and bottom halves of the ith
domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)