Simon Lai's Blog
  • 首頁
  • 歸檔
  • 分類
  • 標籤
  • 關於

Shell基礎筆記 - The Missing Semester of Your CS Education

可惜還是學生的時候不知道有這門好課,雖然已經有些經驗了,但還是想看看這門課能帶給我什麼新東西 快速複習Basics of the Shell Shell = text-based interface for executing commands. Bash (Bourne Again Shell) is widely used. Basic Commands date → Show
2025-03-26
電腦科學 > The Missing Semester of Your CS Education
#shell #the-missing-semester-of-your-cs-education

2033. Minimum Operations to Make a Uni-Value Grid - Medium

前往題目 想法 中位數應該是最靠近所有數字的數 思路 把陣列扁平化,因為位置資訊不重要 扁平化後就可以排序並找到中位數 接著計算步數 只有當前數字減去中位數後,不能以每次x的步伐走到中位數才是invalid的狀況 Codeclass Solution { public int minOperations(int[][] grid, int x) {
2025-03-26
Leetcode > Medium
#Leetcode #心得 #Array #Math #Matrix #Sorting

3394. Check if Grid can be Cut into Sections - Medium

前往題目 想法 不知該如何檢查是否可切成三塊 思路看成是intervals來解 分成x和y座標並排序 垂直和水平方向分開來檢查是否重疊,並記錄不重疊數 輸出結果 Code class Solution { public boolean checkValidCuts(int n, int[][] rectangles) { int[][] x =
2025-03-25
Leetcode > Medium
#Leetcode #心得 #Array #Sorting

如何使用python的venv

當python有問題的時候直接使用venv通常都能解決,甚至每個專案都用venv是最好的,這樣就可以把package分開 要先安裝python3-venv,例如Linuxsudo apt install python3-venv 建立venv目錄python3 -m venv venv 進入venv環境source venv/bin/activate 然後就可以自由安裝套件了,注意每次要安裝都須
2025-03-24
綜合
#venv #python

3169. Count Days Without Meetings - Medium

前往題目 想法 最直觀的就是用set裝滿天數,然後用所有的meetings去排除,最後看size,但很明顯的這太慢了,每個區間有n天,然後有n個區間,就要n^n次了 思路 先依照starting day排序 然後檢查每個區間是否和上一個重疊 是就合併,否則紀錄天數 最後天數減去總天數就是答案 Code網友解答 class Solution { public int coun
2025-03-24
Leetcode > Medium
#Leetcode #心得 #Array #Sorting

macos如何轉換java的JDK版本

安裝JDK之後檢查一下,應有兩個版本/usr/libexec/java_home -V export JAVA_HOME=`/usr/libexec/java_home -v 欲切換的版本` 3.java -version檢查一下是否切換成功 參考
2025-03-21
綜合
#macos #java #jdk

3191. Minimum Operations to Make Binary Array Elements Equal to One I - Medium

前往題目 想法 或許可以用sliding window但對於如何判斷是否應該翻轉bit毫無想法 思路運用Greedy概念,只需要專注在當前的數字,0就翻轉,否則不管,如果valid最後一定全部都是1,否則會有一或兩個0 三個為一個window,第一個為基準判斷是否翻轉 每次翻轉紀錄次數 結束後,如果最後兩位有1或2個0就是invalid 對於如何確定這是可行的並不清楚…但應該可以看作是每次
2025-03-19
Leetcode > Medium
#Leetcode #心得 #Queue #Array #Bit Manipulation #Sliding Window #Prefix Sum

2401. Longest Nice Subarray - Medium

前往題目 想法 忘了有sliding window:D太久沒寫了 思路關鍵是紀錄哪些bit已經被使用,以及利用sliding window鎖定範圍 Code網友解答 class Solution { public int longestNiceSubarray(int[] nums) { int usedBits = 0, l = 0, res =
2025-03-18
Leetcode > Medium
#Leetcode #心得 #Array #Bit Manipulation #Sliding Window

2206. Divide Array Into Equal Pairs - Easy

前往題目 思路這題也十分簡單,只要看是否每個數字都有對應的自己就好 Codeclass Solution { public boolean divideArray(int[] nums) { // Base case if (nums.length < 2) return false; Set<Intege
2025-03-17
Leetcode > Easy
#Leetcode #心得 #Array #Hash Table #Bit Manipulation #Counting

3487. Maximum Unique Subarray Sum After Deletion - Easy

前往題目 思路這題寫出來了 用Set紀錄重複的,且跳過小於1的數字 切記要追蹤並判斷是否全部都是負數,全部都是負數的話反而要輸出最大負數,只要有一個正數(>=0),就一定不會是輸出負數 Codeclass Solution { public int maxSum(int[] nums) { HashSet<Integer> s
2025-03-16
Leetcode > Easy
#Leetcode #心得 #Array #HashSet
12345…36

搜尋

Hexo Fluid