討論串[閒聊] 每日LeetCode
共 719 篇文章

推噓3(3推 0噓 0→)留言3則,0人參與, 1年前最新作者wu10200512 (廷廷)時間1年前 (2024/02/16 03:16), 編輯資訊
0
0
0
內容預覽:
我自己寫是每個數字都算一次二進位轉換. 看解答發現可以用類似DP來解. 338. Counting Bits. class Solution {. public:. vector<int> countBits(int n) {. vector<int> ans(n+1, 0);. for(int i
(還有30個字)

推噓1(1推 0噓 4→)留言5則,0人參與, 1年前最新作者wu10200512 (廷廷)時間1年前 (2024/02/16 02:57), 編輯資訊
0
0
0
內容預覽:
位元運算不看解答真的解不出來. easy也一樣 我好爛. 191. Number of 1 Bits. class Solution {. public:. int hammingWeight(uint32_t n) {. int count=0;. while(n){. count+=n%2;.
(還有1個字)

推噓1(1推 0噓 0→)留言1則,0人參與, 1年前最新作者wu10200512 (廷廷)時間1年前 (2024/02/16 02:38), 編輯資訊
0
0
0
內容預覽:
放進vector後sort. 跟用priority_queue. 誰比較快啊. 1481. Least Number of Unique Integers after K Removals. class Solution {. public:. int findLeastNumOfUniqueInt
(還有332個字)

推噓1(1推 0噓 1→)留言2則,0人參與, 1年前最新作者oin1104 (是oin的說)時間1年前 (2024/02/15 07:05), 編輯資訊
0
0
0
內容預覽:
我也是從最大的開始找. 如果最大的沒辦法弄成合法的多邊型. (最大的邊比其他邊加起來小). 那就把這個邊給排泄掉. 然後找到剩下三個邊都不行的話就是沒有. 那就是回傳-1. class Solution {. public:. long long largestPerimeter(vector<in
(還有380個字)

推噓2(2推 0噓 0→)留言2則,0人參與, 1年前最新作者JerryChungYC (JerryChung)時間1年前 (2024/02/15 05:49), 編輯資訊
0
0
1
內容預覽:
https://leetcode.com/problems/find-polygon-with-the-largest-perimeter. 找出能做出最大多邊形邊長的數組,有則回傳周長,沒有則回傳-1. Python3 code:. --------------------------------
(還有802個字)