2024-02-26 解題區►Leetcode►Easy Leetcode 100 - Same Tree 題目 Problem# 給你兩個 binary tree p 和 q 要你寫一個程式判斷兩棵樹是否一樣。 測資限制# Read More
2024-02-22 解題區►Leetcode►Easy Leetcode 997 - Find the Town Judge 題目 Problem# 有 $n$ 個人標號 $[1, n]$ 其中有一個人是城鎮法官滿足兩個條件: 城鎮法官不相信任何人 其他人都相信城鎮法官 給你一個陣列 trust[i] = [ai, bi] 代表 $a_i$ 相信 $b_i$,回傳法官的編號,沒有的話回傳 -1。 Read More
2024-02-20 解題區►Leetcode►Easy Leetcode 268 - Missing Number 題目 Problem# 給你一個大小 $n$ 的不重覆整數陣列 nums,數字範圍 $[0, n]$,要你回傳唯一不在範圍內的數字。 測資限制# $1 \le n \le 10^4$ Read More
2024-02-20 解題區►Leetcode►Easy Leetcode 231 - Power of Two 題目 Problem# 給你一個整數 n 問你它是不是 $2^x$? Follow up: 不用 loop/recursion? 測資限制# Read More
2024-02-18 解題區►Leetcode►Medium Leetcode 3040 - Maximum Number of Operations With the Same Score II 題目 Problem# 給你一個整數陣列 nums 你可以做三種操作: 刪除開頭兩個數字 刪除結尾兩個數字 刪除頭尾各一個數字 問你最多可以做幾次操作,且每次操作所刪除的數字加起來都要相同 Read More
2024-02-18 解題區►Leetcode►Medium Leetcode 3039 - Apply Operations to Make String Empty 題目 Problem# 給你一個字串 s,每次都從中刪除所有第一次出現的字元,問你刪除到最後一步(再刪除一次就變成空字串)時,所刪除的子字串是什麼? 測資限制# $1 \le s \le 5 \cdot 10^5$ Read More
2024-02-18 解題區►Leetcode►Easy Leetcode 3038 - Maximum Number of Operations With the Same Score I 題目 Problem# 給你一個整數陣列 nums 你每次可以從中刪除頭兩個數字,問你對於這個整數陣列來說,最多可以刪除幾次且每次刪除的數字加總起來要一樣,回傳最多可以刪除的次數。 測資限制# $2 \le n \le 100$ $1 \le val \le 1000$ Read More
2024-02-16 解題區►Leetcode►Hard Leetcode 1481 - Least Number of Unique Integers after K Removals 題目 Problem# 給你一個整數陣列 arr 和一個整數 k ,問你在移除 k 個元素後剩下最少幾種不同的數字? 測資限制# $1 \le n \le 10^5$ $1 \le val \le 10^9$ $0 \le k \le n$ Read More
2024-02-13 解題區►Leetcode►Medium Leetcode 2108 - Find First Palindromic String in the Array 題目 Problem# 給你一個字串陣列 words 回傳第一個是回文的字串,如果沒有的話回傳空字串。 測資限制# $1 \le n, s \le 100$ Read More
2024-02-08 解題區►Leetcode►Medium Leetcode 279 - Perfect Squares 題目 Problem# 給你一個整數 n,回傳最少需要幾個完全平方數加起來等於它? 測資限制# $1 \le n \le 10^4$ Read More