Leetcode-30-Substring with Concatenation of All Words
題目You are given a string s and an array of strings words. All the strings of words are of the same length. A concatenated string is a string that exactly contains all the strings of any permutation of words concatenated. For example, if words = [“ab”,”cd”,”ef”], then “abcdef”, “abefcd”, “cdabef”, “cdefab”, “efabcd”, and “efcdab” are all concatenated strings. “acdbef” is not a concatenated string because it is not the concatenation of any permutation of words. Return an array of the...
Leetcode-18-4Sum
題目Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, c, d < n a, b, c, and d are distinct. nums[a] + nums[b] + nums[c] + nums[d] == target You may return the answer in any order. 題目連結 Example 1 12Input: nums = [1,0,-1,0,-2,2], target = 0Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]] Example 2 12Input: nums = [2,2,2,2,2], target = 8Output: [[2,2,2,2]] 解釋題目題目會給一個 integer array...
Leetcode-16-3Sum-Closest
題目Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. 題目連結 Example 1 123Input: nums = [-1,2,1,-4], target = 1Output: 2Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). Example 2 123Input: nums = [0,0,0], target = 1Output: 0Explanation: The sum that is closest to the target is 0. (0 + 0 +...
Leetcode-15-3Sum
題目Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. 題目連結 Example 1 12345678Input: nums = [-1,0,1,2,-1,-4]Output: [[-1,-1,2],[-1,0,1]]Explanation: nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0.nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0.nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0.The...
Leetcode-11-Container-With-Most-Water
題目You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. Notice that you may not slant the container. 題目連結 Example 1 123Input: height = [1,8,6,2,5,4,8,3,7]Output: 49Explanation: The above vertical lines are represented by...
set windows remote mode on windows pro
啟用 windows pro按照此github的教學,升級成 windows pro Step 1. 啟用遠端桌面 進入設定頁面。 點擊 系統 → 遠端桌面。 將「啟用遠端桌面」切換為 開,並按下 確認。 電腦名稱會顯示在此處,記下來以供日後連線使用。 Step 2. 允許遠端桌面通過防火牆 進入控制台,點擊系統及安全性 → Windows Defender 防火牆。 點擊 允許應用或功能通過 Windows Defender 防火牆。 找到「遠端桌面」,確保「私人」和「公用」網路都已勾選。 Step 3. 設定 DHCP 允許自動從路由器或 DHCP 伺服器獲取 IP 位址。 進入設定頁面,點選網路和網際網路。 將 IP指派和伺服器指派,設成自動。 Step 4. 跨網路連線(設置端口轉發)(Port Forwarding) 進入路由器管理介面,「預設閘道」的 IP 位址,打在Google。 使用者名稱:admin,密碼: password (可修改,Hitron) 查詢電腦的內網 IP (可能會一直變,路由器指派的)(動態IP): ipconfig...
Indexing Sort
Indexing Sort 有一堆數字,數字的值介於 1~n 之間,數字的個數大概在 n 附近。 盡最大努力做排序,讓 nums[index] = index。 若排序後,仍有 nums[index] != index 非常有可能是問題的答案。 目標12index 1 2 3 ... n n+1 (n+1個數)value 1 2 3 ... n 6 (值介於1~n) 思路12345678index 1 2 3 4 5 .... n-1 n n+1ex: 1 3 5 4 2 1 5 3 4 2 (走到 index 2, 將 value 3 送到正確的位置(index 3) => 3、5 對調 1 2 3 4 5 (走到 index 2, 將 value 5 送到正確的位置(index 5) => 5、2 對調index 1 2 3 4 5 6 7 8 ... n-1 n n+1ex: 1 2 3 4 5 8 8 1 2 3 4 5 8 8 (走到 index 6, 不用交換 =>...
Quick Select
Quick Select 找 K-th element 時間複雜度: 平均 O(N) 目標123456 pivotS S S O O L L L L LS: 小於 pivot 的數O: 等於 pivot 的數L: 大於 pivot 的數 過程123456S S S O O X X X X L L L L L i t ji: 指向 S 的後一個數j: 指向 L 的前一個數t: 指向未知的數 分堆後123456S S S O O O L L L L La i j bif(b-j >= k) => find k-th largest in [L]else if(b-i+1 >= k) => k-th largest is pivotelse => find "k-(b-i+1) th" largest in [S] 程式12345678910111213141516171819202122232425int...