Roy 的解題紀錄

Home Archives About
2024-01-14
解題區►Leetcode►Hard

Leetcode 1657 - Determine if Two Strings Are Close

題目

Problem#

給你兩個字串 word1, word2 你可以對它做以下兩個操作:

  1. 交換任意兩個字元 e.g. abcde -> aecdb
  2. 選擇一組字元(不限長度、可以不用連續),可以互相交換字元 e.g. aacabb -> bbcbaa

你可以做無限次操作,把 word1 和 word2 做完操作後會一樣回傳 true 反之回傳 false。

Read More

Share Comments
  • Leetcode
  • sorting
  • string
  • 解題紀錄
2024-01-12
解題區►Leetcode►Medium

Leetcode 2085 - Count Common Words With One Occurrence

題目

Problem#

給你兩個字串鎮列 words1 和 words2 問你兩個陣列都只出現一次的字串數量有多少?

測資限制#

  • $1 \le n \le 1000$

Read More

Share Comments
  • Leetcode
  • hashmap
  • 解題紀錄
2024-01-10
解題區►Leetcode►Hard

Leetcode 2385 - Amount of Time for Binary Tree to Be Infected

題目

Problem#

給你一個 binary tree 的 root 上面的值都不重複,另外給你一個數字 start,問你從該數字的 node 為 root,最大深度為多少?

測資限制#

  • $1 \le n \le 10^5$
  • $1 \le val \le 10^5$

Read More

Share Comments
  • Leetcode
  • bfs
  • graph
  • 解題紀錄
2024-01-09
解題區►Leetcode►Medium

Leetcode 872 - Leaf-Similar Trees

題目

Problem#

Leaf value sequence 為二元樹的所有葉節點(Leaf),從左至右輸出的序列。
給你兩個二元樹,問你兩個 leaf value sequence 是否一樣?

測資限制#

Read More

Share Comments
  • Leetcode
  • dfs
  • 解題紀錄
2024-01-05
解題區►Leetcode►Medium

Leetcode 300 - Longest Increasing Subsequence

題目

Problem#

給你一個陣列,回傳其最長嚴格遞增子序列(LIS)。

測資限制#

  • $1 \le n \le 2500$

Read More

Share Comments
  • DP
  • LIS
  • Leetcode
  • binary search
  • 解題紀錄
2024-01-04
解題區►Leetcode►Medium

Leetcode 2870 - Minimum Number of Operations to Make Array Empty

題目

Problem#

給你一個正整數陣列 nums,你對陣列做以下操作:

  • 從裡面刪掉 2 個一樣的數字
  • 從裡面刪掉 3 個一樣的數字

回傳最少要多少次操作,能使 nums 變空?如果無法則回傳 -1。

Read More

Share Comments
  • Leetcode
  • greedy
  • 解題紀錄
2024-01-03
解題區►Leetcode►Medium

Leetcode 2125 - Number of Laser Beams in a Bank

題目

Problem#

給你一個 $m \times n$ 的陣列 bank 裡頭只包含 0(空的), 1(機器),對於相鄰兩列的機器,對於第 $i$ 列的每台機器會和第 $j$ 列的每台機器用雷射相連,中間不能間隔其他機器,問你總共有多少條雷射?

測資限制#

  • $1 \le m, n \le 500$

Read More

Share Comments
  • Leetcode
  • array
  • matrix
  • 解題紀錄
2024-01-02
解題區►Leetcode►Medium

Leetcode 2610 - Convert an Array Into a 2D Array With Conditions

題目

Problem#

給你一個整數陣列 nums 你要把它根據以下規則排成一個二維陣列回傳。

  • 陣列的每列元素皆不重複
  • 列的數量應越少越好

如果有多組解則回傳任一一種即可

Read More

Share Comments
  • Leetcode
  • array
  • 解題紀錄
2023-12-27
解題區►Leetcode►Medium

Leetcode 1578 - Minimum Time to Make Rope Colorful

題目

Problem#

有 $n$ 個氣球,每個氣球是 color[i] 顏色,顏色不能連續出現,如果有相鄰的顏色的話,可以花 neededTime[i] 戳破第 $i$ 個氣球。
問你總共最小要花多少時間讓所有氣球的顏色不連續?

測資限制#

Read More

Share Comments
  • Leetcode
  • greedy
  • 解題紀錄
  • 雙指標
2023-12-27
解題區►Leetcode►Medium

Leetcode 1155 - Number of Dice Rolls With Target Sum

題目

Problem#

你有 $n$ 個 $k$ 面骰子,點數是 $1$ 到 $k$ ,給你一個目標數字 $t$,問你連續投骰子,最後點數加總起來等於 $t$ 的方法數有多少?
答案可能很大,因此回傳前要模除 $10^9+7$ 。

測資限制#

  • $1 \le n, k \le 30$
  • $1 \le t \le 1000$

Read More

Share Comments
  • DP
  • Leetcode
  • 解題紀錄
« Prev123456…23Next »

Categories

  • 解題區
    • CSES
      • Introductory Problems
    • Leetcode
      • Easy
      • Hard
      • Medium
    • Uva

Tags

  • 2D 格子
  • BFS
  • Bit Manipulation
  • CSES
  • Class
  • DP
  • Design
  • Game Thoery
  • LCS
  • LIS
  • Leetcod
  • Leetcode
  • Stack
  • Uva
  • array
  • backtracking
  • bfs
  • binary search
  • bitwise 枚舉
  • bst
  • cycle
  • cycle detection
  • dfs
  • dijkstra
  • disjoint set
  • geometry
  • graph
  • greedy
  • hashmap
  • interval
  • linked list
  • map
  • math
  • matrix
  • matrixe
  • minumum spanning tree
  • monotonic stack
  • ordered set
  • prefix sum
  • priority queue
  • simulation
  • sliding window
  • sort
  • sorting
  • stack
  • string
  • 二分圖
  • 二分答案
  • 暴搜
  • 背包
  • 著色問題
  • 解題紀錄
  • 雙指標

Tag Cloud

2D 格子 BFS Bit Manipulation CSES Class DP Design Game Thoery LCS LIS Leetcod Leetcode Stack Uva array backtracking bfs binary search bitwise 枚舉 bst cycle cycle detection dfs dijkstra disjoint set geometry graph greedy hashmap interval linked list map math matrix matrixe minumum spanning tree monotonic stack ordered set prefix sum priority queue simulation sliding window sort sorting stack string 二分圖 二分答案 暴搜 背包 著色問題 解題紀錄 雙指標

Archives

  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • July 2022
  • March 2022
  • February 2022
  • May 2021
  • March 2021
  • September 2019
  • June 2019
  • May 2019
  • February 2019

Recent Posts

  • Leetcode 2181 - Merge Nodes in Between Zeros
  • Leetcode 1509 - Minimum Difference Between Largest and Smallest Value in Three Moves
  • Leetcode 409 - Longest Palindrome
  • Leetcode 1863 - Sum of All Subset XOR Totals
  • Leetcode 861 - Score After Flipping Matrix
© 2024 Roy
Powered by Hexo
Home Archives About