blackdiz

@blackdiz

Joined on Sep 10, 2019

  • View the book with " Book Mode". Questions LeetCode 344. Reverse String (Easy) LeetCode 104. Maximum Depth of Binary Tree (Easy) LeetCode 136. Single Number (Easy) LeetCode 283. Move Zeroes (Easy) LeetCode 412. Fizz Buzz (Easy) LeetCode 206. Reverse Linked List (Easy)
     Like  Bookmark
  • Projection 是指 select 時只回傳指定欄位,在 Spring Data 中有幾種情境。 假設有個 Entity 為: @MappedSuperclass public class BaseEntity { @Column(name = "CreateTime", columnDefinition = "datetime2") private Date createTime; public Date getCreateTime() {
     Like  Bookmark
  • Node.js 當 main thread 執行結束後會進入 event queue 迴圈中。每次 event queue 迴圈中有下面 6 個階段,每個階段會執行它相應的 queue 內的 task,當它的 queue 內的 task 執行完畢後會執行完所有 porcess.nextTick() 放入 nextTickQueue 中的 task,接著再執行完 Promise 放入 micro task queue 中的 task,並且會等到 nextTickQueue 和 micro task queue 全部執行完畢後才會進入下個階段。 所以如果 Promise resolve 中會產生新的 Promise 或 process.nextTick 會呼叫新的 process.nextTick 則 micro task queue 階段就會一直執行下去而卡住 event queue 讓程式無法回應 request。 比方: const f = () => { process.nextTick(() => console.log(1)); Promise.resolve().then(() => console.log(2)); }; f();
     Like  Bookmark
  • Medium Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container. Example 1: Input: height = [1,8,6,2,5,4,8,3,7] Output: 49
     Like  Bookmark
  • Medium Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3.
     Like  Bookmark
  • 在無網路的情況下不用 root 安裝 ansible 的方法 先在有網路的主機上用 pip 下載 ansbile 安裝包和其依賴包pip download ansible -d . 將 pip 的安裝包和 ansible 安裝包及其依賴包複製到要安裝的主機上 Download pip 解壓縮 pip 安裝包 安裝 pip// 解壓縮 pip 後進到目錄內執行 python setup.py install --user
     Like  Bookmark
  • 如果今天想要實作如 google 搜尋列中的自動補完功能,通常會先有一個字典結構存放關鍵字, Trie 是一種樹狀結構也稱為字典樹,用以在大量字串中快速找尋是否存在該字串。此外,Trie 也有人叫前綴樹,因為它是由字串間相同的前綴文字組成。 一個典型的 Trie 如下: 如果我們順著 Root 往下走,每次隨著節點走到 Leaf 時都可以得到一個字串,如上圖我們可以拼出 CAR、CAT、DOT 3 個字串。其中 Trie 的 Root 節點是不存放文字的。 所以今天如果要確認某個字串是否存在於我們的字典裡,只要依序將該字串從頭開始從 Trie 的 Root 出發,只要相同,我們就取出下個文字看看是否和下個子節點相同,一直到該字串沒有文字可以取出來比對就表示存在,如果中途有不同的子節點或者是已經走到 Leaf 但該字串尚未比對完就表示不存在字典中。 比方今天我們用 CA 比對,先從 C 開始,第一步有節點 C 和 C 相同,所以我們接著取出 A 和 C 的子節點比對,而 C 的子節點是 A 也相同,這時我們要比對的字串已經到尾巴了,所以表示 CA 存在於字典中。
     Like  Bookmark
  • Easy Given a string s and a string t, check if s is subsequence of t. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ace" is a subsequence of "abcde" while "aec" is not). Follow up: If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code? Credits:
     Like  Bookmark