[已解決][C++] No matching member function for call to ‘push_back’ error
在使用 C++ 的標準模板函式庫(Standard Template Library, STL)時,若是在使用 deque 或 vector 新增元素時遇到以下錯誤:
Read More »[已解決][C++] No matching member function for call to ‘push_back’ error在使用 C++ 的標準模板函式庫(Standard Template Library, STL)時,若是在使用 deque 或 vector 新增元素時遇到以下錯誤:
Read More »[已解決][C++] No matching member function for call to ‘push_back’ errorIn 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
.
在撰寫 C++ 的過程中,我們若是想要儲存一筆陣列資料,除了使用最基礎的 array 資料結構外,就是使用標準函式庫中的 vector 了。然而並不是所有的資料都是單純的一維資料,有時我們可能有著需求要建立二維甚至更高維的初始化資料;本篇文章就是紀錄該如何做到這件事的筆記。
Read More »[C++] 二維或更高維的 std::vector 初始化筆記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 Integer