leetcode

含有「leetcode」共 457 篇內容
全部內容
發佈日期由新至舊
[Medium] 解法 : Math 題意 : 有兩列,第一列會有 x 朵花,第二列則有 y 朵。有兩個人,Alice 和 Bob,Alice 會先挑選其中一朵花丟掉,再來換 Bob 挑選花丟掉,如果丟掉花後,兩列都沒有花了,則最後挑選花的人獲勝。 給定 n 與 m,去看共有幾種 (x, y
Thumbnail
[Medium] 解法 : DP + sliding window 題意 : 給定 n、k、maxPts 起始分數為 0。 分數小於 k 時,會隨機抽一個介於 1 到 maxPts 的整數點數,每次抽牌機率相同且獨立。 當分數達到或超過 k 時停止抽牌。 回傳最終分數 不超過 n 的機率
Thumbnail
Description You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of thei
Thumbnail
Soup Servings - LeetCode Description You have two soups, A and B, each starting with n mL. On every turn, one of the following four serving operatio
5/5LeetCode
將水果放入籃子 - LeetCode --- Fruit Into Baskets - LeetCode Description You are visiting a farm that has a single row of fruit trees arranged from......
Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly.....
Thumbnail
5/5leetcode
[Medium] 解法 : BFS 題意 : 給定一個長度為 n 的整數陣列 nums,從索引 0 開始,目標是走到索引 n - 1。 對於任意索引 i,可進行以下操作: 相鄰跳躍:索引仍在陣列範圍內,可以跳到 i + 1 或 i - 1。 質數傳送:如果 nums[i] 是一個質數
information link:Two Sum - LeetCode Description:Given an array of integers nums and an integer target, return indices of the two numbers such......
5/5leetcode
[Medium] 解法 : BFS 題意 : 給定一個二維陣列,元素為整數,與一個整數 k。其中被 0 圍起來的整數區塊為 island,island value 為區塊內元素數值的總和。一個合法的小島是其 value 可以被 k 整除,求出符合此條件的所有小島,並將 value 加總回傳。
Thumbnail
[Easy] 解法 : Traversal 題意 : 給定一個字串,判斷其是否合法。合法的條件如下,全部皆需要滿足 最少需要 3 個字元 字串中只能含有英文字母與數字 字串中至少要有一個母音 (vowel) 字串中至少要有一個子音 (consonant) 解題思路 : 用一個 s
Thumbnail