KA UT MA

@XVs32

進入研究所後深深體會到學海無涯的小小菸酒生,趁著最後的學生生涯,有事沒事就會搞點沒甚麼實際用途的 side project 來折騰自己。

Joined on Jan 3, 2018

  • tmux 的全稱是 Terminal Multiplexer,直譯過來就是終端(Terminal)多工器(Multiplexer),這個工具可以在單一 screen 之下 create, attach, detach 多個終端,熟悉之後十分好用。只是和 vim,vi 系列相同,所有操作皆能且只能使用鍵盤,不像 GNOME Terminal 一樣有直觀的 GUI 介面,算不上友善的學習曲線使人又愛又恨。關於 tmux 的基本概念和入門組合鍵,G. T. Wang 的文章提供了很不錯的繁體中文資料,本篇的重點在於如何配合 shell script 和 tmux 來快速建立一個順手的工作區。   you can do this keyword: tmux,script 自動化建立 tmux 工作區 建立腳本 首先,當然是創建一份腳本,第一行請記得加上 shebang。
     Like 1 Bookmark
  • 前言 轉眼就在日本工作快半年了,想說就來整理一下求職當下的記錄吧。先說一下小弟我的狀況,原本其實是沒有來日本工作的計劃,打算就老老實實GG輪班救台灣的。只是剛好修個日文課,剛好老師介紹下參加了幾場面試,誤打誤撞的就拿到了還算可以的內定。瞄著日本的綠卡傻傻的就跑來了。所以說人生啊,緣分真的很重要。而計劃,永遠趕不上變化。 硬件(個人背景) 先簡明扼要地說明一下我的背景,這樣你比較知道這對你來說有沒有參考價值: 交大資工學士 (成績墊底,底到不能更底的那種) 成大電通碩士 (成績還行,能領個獎學金不用繳學費的那種) 有N1證照 (交大資工人均 N1 (沒XD),我聽說讀寫都不強,有考過的都知道,那只是張廢紙) 英文沒證照,但聽說讀寫都還行 (論文傻傻的跑去用英文寫的等級[好孩子別亂試,一個沒弄好就準備延畢吧QQ])
     Like 2 Bookmark
  • Introduction 緣起筆者回國了,然後就 ChatGPT 就封我 IP 了 QQ。 免費仔只好上個 OpenVPN 來繞一下,只是 OpenVPN 並沒有只適用於瀏覽器的選項。 於是一旦打開 VPN,其他連線也一併慢了下來。 回頭問 ChatGPT 後,提示可以用 Split tunneling 來指定要使用 VPN 的 IP。 IP 搜尋 首先我們要從目標網站的 Host name (ex. chat.openai.com)找到 IP (ex. 104.18.3.161)。 你可以直接Google,或是使用 https://ssl-tools.net/ 之類的網站。
     Like  Bookmark
  • Revision record version comment author v0.1.0 document built Marco Ma
     Like  Bookmark
  • Revision record version comment author v0.1.0 document built Marco Ma
     Like  Bookmark
  • 給定一個已排序的 int 陣列, 要求移除陣列內出現數超過兩次的元素, 同時要求 O(1) 空間複雜度。 難度不高的 Medium 題目, 但需要注意邊界問題。 由於給定的陣列有經過排序, 因此只需要和上一個元素作比對, 而不必對整個陣列作搜尋。 發現同樣的元素時, 則把 flag 改為 true, 若 flag 已經為 true, 則代表元素已經出現超過兩次。可以跳過該元素。 注意給定陣列大小可為 0, 需要進行例外處理。 題目 Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.
     Like  Bookmark
  • 目錄 [TOC] 簡介 本文件記錄建立一個 ext4 檔案系統的過程和觀察其空間分配機制而進行的實驗。 使用 ubuntu 18.04 為作業系統,在 Transcend 64GB 隨身碟上建立一個 ext4 檔案系統。 建立 ext4 找到儲存裝置 第一步是找出用於建立 ext4 的儲存裝置,這邊使用的是隨身碟。
     Like  Bookmark
  • 給定一個字串和一連串的 round shift 操作,round shift 格式為[方向,距離]。求完成 round shift 操作後的字串。 round shift 操作會互相抵消,所以整合所有操作,實際上 shift 一次就可以了。 題目 You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left shift) or 1 (for right shift). amount is the amount by which string s is to be shifted. A left shift by 1 means remove the first character of s and append it to the end.
     Like  Bookmark
  • 給定一個只有 0 和 1 的陣列,求 0 和 1 數量相等的最大子陣列。 又是一題 hash table(好啦,其實是前綴和),求各前綴的 0,1 數量差,若有兩個前綴帶有相同 0,1 數量差,則這兩個前綴相減結果會是一個 0 和 1 數量相等的子陣列。 而 hash table 可用於記錄各數量 0,1 的對應前綴。 順帶一提,因為是要找最大子陣列,hash table 只要記錄每個 0,1 數量差最早找到的前綴就可以了(越後期找到的,距離肯定越短啊)。 題目 Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1:
     Like  Bookmark
  • 給定一個非空的整數陣列,每次取出最大的兩個值相減,並把差值放回陣列,求陣列最後剩下的數字。 沒甚麼好說的,直接模擬整個過程。為了方便取得最大值,這邊使用 priority queue。 題目 We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is: If x == y, both stones are totally destroyed;
     Like  Bookmark
  • 給定一棵二元樹,問任意兩個節點的最長距離是多少。 最長路徑不一定會經過根節點,但一定會經過擁有左右子節點的節點(根節點除外喔)。 這是因為如果一個節點只有一個子節點,那麼只要往子節點方向走就可以得到更長的距離了(除非你走到葉子〔末端〕,無法再往下走)。 但如果擁有左右子節點,那麼就可以同時往左右走,而無視掉從父節點來的路徑。 例如: 1 / \ 2 3
     Like  Bookmark
  • 給定兩個只包含字母和#的字串,其中#代表 backspace,問兩個字串在處理完 backspace 後一否一致。 從字串末尾開始掃描,即可把 backspace 轉化為 delete,這時候就變成遇到#就無視下一個字元了。 然而#可能會連續出現,所以需要記錄#連續出現多少次,然後無視同樣多個字元。 題目 Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue empty.
     Like  Bookmark
  • 給定一個 linked list, 回傳 linked list 的中央節點。 本題屬於 linked list 的基本操作,解法是快慢機,使用一個 step = 1 的指標,和一個 step = 2 的指標。當 step = 2 的指標指向 linked list 末端時,step = 1 的指標會正好指向 linked list 中央。 題目 Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node.
     Like  Bookmark
  • 給定一個非空的整數陣列,問存在多少個 x,其中 x 和 x+1 同時是陣列的元素。 把陣列排序,並遍歷一次,遍歷時檢查下一個更大的元素是不是 x+1。 題目 Given an integer array arr, count element x such that x + 1 is also in arr. If there're duplicates in arr, count them seperately.
     Like  Bookmark
  • 給定一組字串,把具有相同字元(不限順序)的字串分在同一組,並輸出各組字串。 例如 eat 和 tea 在同一組。 而 eat 和 eaf 則不在同一組。 這題有兩種解法,分別是陣列或排序。 陣列解法是為每個字串建立長度為 26 的 int 陣列。統計其中各個字母的出現次數,並和其他字串的統計比對。例如有字串aacd,則其統計陣列為[2,0,1,1,0,0,...,0]。 為求加速可以建立 hash table,以字串 ASCII sum 作為 key。免去每次和其餘所有字串統計陣列比對。 但考慮極端情況,若所有字串的 ASCII sum 都重複,而且所有字串都不同組,那麼比對次數將會是 O(N^2)。
     Like  Bookmark
  • 給定一個整數陣列,順序找出各個區間最小、最大值之差的和。 就...遍歷的途中先找區間最小,再找區間最大就好了... PS. 0x7fffffff 是 32 位有號 int 的最大值。 題目 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).
     Like  Bookmark
  • 完成 stack 的 push, pop, top, min 四種功能。 用 python 來寫基本沒有意義...各項功能都有內建。 push 可用 append top 可用 stack[-1] 當然,也可以考慮自己實現一份來提高效率,但... 內建好了就用內建吧,除非對效能有很高要求(然而對效能有要求就不太應該選 python 了) 題目 Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
     Like  Bookmark
  • 求最大連續區間和。唯一需要注意的是,題目要求至少包含一個元素,也就是說最小值不一定為零。 記錄區間和,基於 greedy 在遇到區間和小於零的時候放棄當前區間和。 題目 Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4],
     Like  Bookmark
  • 給定一個整數陣列,把陣列中所有的零移至陣列最後,並且不能影響到其他元素的順序。 這題可以使用快慢指標,一個快指標指向讀取到的位置,另一個慢指標指向寫入到的位置。快慢指標在每輪寫入非零值後加一,快指標在讀取到零值時也加一,當快指標指向陣列末尾時,慢指標後方所有元素皆更改為一。 題目 Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12]
     Like  Bookmark
  • 給定一個整數陣列,重複把各位數字各自平方再相加。問結果會否收儉至1。 以hash table記錄各輪出現的數字,首次重複出現的數字若為1,則輸出True,否則輸出False。 題目 Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers. Example:
     Like  Bookmark