Aji-Hsu

@Aji-Hsu

Hsu, Cheng-Yu ~ NYCU-CS

Joined on Jan 18, 2023

  • Aji Hsu 2025/04/15 Usage To efficiently update and query prefix sums dynamically. Compare to Traditional Prefix Sum Traditionalupdate: TC = O(N) get: TC = O(1) Binary Indexed Tree
     Like  Bookmark
  • Types given nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; prefix sum starting from nums[0], with prefixSum.length = nums.length.prefixSum = { 1, 3, 6, 10, 15, 21, 28, 36, 45 }; prefix sum starting from 0, with prefixSum.length = nums.length + 1.prefixSum = { 0, 1, 3, 6, 10, 15, 21, 28, 36, 45 }; How to write (type1 as examples) 1. Using iteration int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int[] prefixSum = new int[nums.length];
     Like  Bookmark
  • About this article About LeetCode website and Codes To ensure code quality, I have solved all SQL questions on LeetCode and compared my solutions with others. The Questions on LeetCode focus on writing queries efficiently. About learning MySQL Instead of learning a broad range of operations in MySQL, solving questions on LeetCode allows me (and perhaps you) to take deep dive into writing MySQL queries. Learning deeply can truly make you indispensable. You can always refer to documentation as you need, but the skill of writing queries is not something you can simply find in the documentation. Easy Questions
     Like  Bookmark
  • Sliding Window 2024/12/14 What is Sliding Window Two variable front and back form a range [front, back]. When front and back is moving from left to right, you can perform some calculation dynamically. Total Time Complexity is O(N). [front, back] is inclusive both side. Main Idea Moving back++ and check if [front, back] satisfies your requirements.
     Like  Bookmark
  • LeetCode Daily Challenge 2024/10/29 2684. Maximum Number of Moves in a Grid sol1 : using BFS This code checks if (i, j) is reachable. If so, it adds the position to the queue. I used depth to monitor the current column, and the maximum depth indicates the maximum number of moves possible (starting from column 0). Always create int[] diri and int[] dirj to represent the directions for moving on the grid, and use a loop to perform all the movements. When dealing with each column, boolean[] visit checks if the row has been visited, and is reset to all false when moving to the next column. LinkedList<Pair> Q is a queue dealing with in & out of each node(i, j) Code: import java.util.LinkedList;
     Like 1 Bookmark
  • LeetCode Daily Challenge 2024/10/30 1671. Minimum Number of Removals to Make Mountain Array main idea : LIS/LDS approach : keep track of the maximum of a increasing sequence example : given a sequence of numbers : [0, 1, 3, 5, 9, 15, 16, 4, 10, 11, 12, 13, 14]situation : arr = [0, 1, 3, 5, 9, 15, 16] Note that :The index of a number x means that if a sequence ends with x, then its maximum increasing length equals the index + 1. For example, the maximum length of a sequence that ends with 15 is [0, 1, 3, 5, 9, 15], and the index + 1 is the length of the sequence.sequence. Next number = 4 It can easily be observed that 4 and 5 are larger than [0, 1, 3]; moreover, a sequence that ends with 4 is more likely to be smaller than the next number. Operation: Find the upper bound of the original sequence and change it to the number 4.
     Like  Bookmark
  • 2024/06/12 Collections Framework 處理資料結構 集合的大小可以自動改變 皆有toString()方法,可以直接輸出 下圖為架構(每個區塊皆是interface) graph TD Collection-->Set Collection-->List
     Like  Bookmark
  • 以下內容來自我至今所學,若有不正確內容歡迎指教 此文章目標是讓物件導向能夠簡單理解,並且給讀者更深入的觀念,方便銜接 進入物件導向的世界 為什麼需要物件導向? 當撰寫長到爆的程式時你開始會有==第三者閱讀的困難==及==維修的困難==,因此這個時候就是物件導向派上用場的地方!負責將每個區塊以類別分類,物件化東西,有系統地整理程式碼 物件導向不僅能解決上述問題,還能自己寫一個==類別==很像是做出一個咖啡機,如此一來,你想要喝咖啡的時候,就直接把咖啡機拿出來使用,相當方便 物件導向是什麼?-RPG遊戲的角色與技能 類別與物件:
     Like 2 Bookmark