[Python] 使用 eventlet 函式庫在程式執行超過一定時間後自動終止程式
最近我在進行程式撰寫時,有了這樣一個奇怪的需求:我的程式解決一個問題基本會在一分鐘左右,但是如果超過一分鐘我需要放棄這項任務,繼續轉向下個任務。
Read More »[Python] 使用 eventlet 函式庫在程式執行超過一定時間後自動終止程式最近我在進行程式撰寫時,有了這樣一個奇怪的需求:我的程式解決一個問題基本會在一分鐘左右,但是如果超過一分鐘我需要放棄這項任務,繼續轉向下個任務。
Read More »[Python] 使用 eventlet 函式庫在程式執行超過一定時間後自動終止程式In a town, there areRead More »LeetCode: 997-Find the Town Judge 解題紀錄n
people labeled from1
ton
. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: 1. The town judge trusts nobody. 2. Everybody (except for the town judge) trusts the town judge. 3. There is exactly one person that satisfies properties 1 and 2. You are given an arraytrust
wheretrust[i] = [ai, bi]
representing that the person labeledai
trusts the person labeledbi
. Return the label of the town judge if the town judge exists and can be identified, or return-1
otherwise.
You are given a list of songs where the ith song has a duration ofRead More »LeetCode: 1010-Pairs of Songs With Total Durations Divisible by 60 解題紀錄time[i]
seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indicesi
,j
such thati < j
with(time[i] + time[j]) % 60 == 0
.
Given theRead More »LeetCode: 938-Range Sum of BST 解題紀錄root
node of a binary search tree and two integerslow
andhigh
, return the sum of values of all nodes with a value in the inclusive range[low, high]
.
The power of the string is the maximum length of a non-empty substring that contains only one unique character. Given a string s, return the power of s.Read More »LeetCode: 1446-Consecutive Characters
Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number.
Return the decimal value of the number in the linked list.
Read More »LeetCode: 1290-Convert Binary Number in a Linked List to IntegerThe Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, return the Hamming distance between them.Read More »LeetCode: 461-Hamming Distance 解題紀錄