Roy 的解題紀錄

Home Archives About
2024-03-20
解題區►Leetcode►Medium

Leetcode 1669 - Merge In Between Linked Lists

題目

Problem#

給你兩個 linked-list A 和 B 長度分別是 n 和 m,並給你兩個正整數 a 和 b 代表要從 A 中移除第 a 個到第 b 個 node,之後用 B 替代,要你回傳替代後的結果。

測資限制#

Read More

Share Comments
  • Leetcode
  • linked list
  • 解題紀錄
2024-03-15
解題區►Leetcode►Medium

Leetcode 238 - Product of Array Except Self

題目

Problem#

給你一個整數陣列 nums,要你回傳答案陣列 answer[i] = nums[0] * ... * nums[i-1] * nums[i+1] * ... * nums[n-1] (也就是除了 nums[i] 之外的相乘)
時間複雜度必須在 $O(n)$。

測資限制#

  • $2 \le n \le 10^5$
  • $-30 \le val \le 30$

Read More

Share Comments
  • Leetcode
  • prefix sum
  • 解題紀錄
2024-03-13
解題區►Leetcode►Easy

Leetcode 2485 - Find the Pivot Integer

題目

Problem#

給你正整數 $n$ 要你找到 pivot $i$ 使得 $1+2+\cdots +i = i + (i+1) + (i+2) + \cdots + n$,如果找不到則回傳 -1

測資限制#

  • $1 \le n \le 1000$

Read More

Share Comments
  • Leetcode
  • prefix sum
  • 解題紀錄
2024-03-11
解題區►Leetcode►Medium

Leetcode 791 - Custom Sort String

題目

Problem#

給你兩個字串 order 和 s,要你把 s 按照 order 的字母順序排序,沒出現在裡面的字母位置隨意,回傳排序後的字串。

測資限制#

  • $1 \le \text{order} \le 26$
  • $1 \le \text{s} \le 200$

Read More

Share Comments
  • Leetcode
  • hashmap
  • sort
  • 解題紀錄
2024-03-03
解題區►Leetcode►Medium

Leetcode 3067 - Count Pairs of Connectable Servers in a Weighted Tree Network

題目

Problem#

給你一個有 $n$ 個點的無向圖,另外給你一個整數 ss。

定義點 a 與點 b 之間是否是透過點 c 連接的,必須符合以下條件:

Read More

Share Comments
  • Leetcode
  • dfs
  • graph
  • 解題紀錄
2024-03-01
解題區►Leetcode►Easy

Leetcode 2864 - Maximum Odd Binary Number

題目

Problem#

給你只有 0 和 1 (至少包含一個) 的字串 s ,你可以將 bit 自由交換位置,問你最大的奇數是多少?

測資限制#

  • $1 \le n \le 100$

Read More

Share Comments
  • Leetcode
  • greedy
  • 解題紀錄
2024-02-26
解題區►Leetcode►Easy

Leetcode 100 - Same Tree

題目

Problem#

給你兩個 binary tree p 和 q 要你寫一個程式判斷兩棵樹是否一樣。

測資限制#

Read More

Share Comments
  • Leetcode
  • dfs
  • graph
  • 解題紀錄
2024-02-22
解題區►Leetcode►Easy

Leetcode 997 - Find the Town Judge

題目

Problem#

有 $n$ 個人標號 $[1, n]$ 其中有一個人是城鎮法官滿足兩個條件:

  1. 城鎮法官不相信任何人
  2. 其他人都相信城鎮法官

給你一個陣列 trust[i] = [ai, bi] 代表 $a_i$ 相信 $b_i$,回傳法官的編號,沒有的話回傳 -1。

Read More

Share Comments
  • Leetcode
  • graph
  • 解題紀錄
2024-02-20
解題區►Leetcode►Easy

Leetcode 268 - Missing Number

題目

Problem#

給你一個大小 $n$ 的不重覆整數陣列 nums,數字範圍 $[0, n]$,要你回傳唯一不在範圍內的數字。

測資限制#

  • $1 \le n \le 10^4$

Read More

Share Comments
  • Leetcode
  • hashmap
  • 解題紀錄
2024-02-20
解題區►Leetcode►Easy

Leetcode 231 - Power of Two

題目

Problem#

給你一個整數 n 問你它是不是 $2^x$?

Follow up: 不用 loop/recursion?

測資限制#

Read More

Share Comments
  • Bit Manipulation
  • Leetcode
  • math
  • 解題紀錄
« Prev1234…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