原创 leetcode:844. Backspace String Compare

題目: Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a back

原创 bert 原理及源碼分析(一)

全稱:Bidirectional Encoder Representations from Transformers,即雙向 transformer的encoder 表示。 bert 的結構圖 中間的神經網絡爲 transfor

原创 GloVe 與 fasttext

glove 對於一個詞 i 出現的次數爲 XiX_iXi​,在其某個窗口範圍內的詞 j 出現的次數爲 XijX_{ij}Xij​,XijX_{ij}Xij​ 可以直接得到,XiX_iXi​ 爲所有 XijX_{ij}Xij​ 的累

原创 leetcode: 242. Valid Anagram

題目: Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "ana

原创 劍指 offer:兩個鏈表的第一個公共節點、數字在排序數組中的個數、二叉樹的深度

兩個鏈表的第一個公共節點 題目描述 輸入兩個鏈表,找出它們的第一個公共結點。 分析 首先要明白公共節點的含義:即兩個鏈表從某個節點開始重合,重合的第一個節點即爲第一個公共節點。 那麼最直接的想法就是從後往前推,找到第一個不相同的節

原创 leetcode: 235. Lowest Common Ancestor of a Binary Search Tree

題目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. Accordi

原创 leetcode: 98. Validate Binary Search Tree

題目: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows:

原创 使用 tf-idf 提取關鍵詞

tf-idf 的簡要介紹: tf:term frequency。某個關鍵詞在整篇文檔中出現的頻率 idf:inverse document frequency。逆文檔頻率。某個詞在所有文檔中出現的頻率。 tf 公式: tfij=n

原创 leetcode:15. 3Sum

題目: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique

原创 leetcode:25. Reverse Nodes in k-Group

題目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a posit

原创 劍指 offer:把字符串轉換成整數、數組中重複的數字

把字符串轉換成整數 題目描述 將一個字符串轉換成一個整數(實現Integer.valueOf(string)的功能,但是string不符合數字要求時返回0),要求不能使用字符串轉換整數的庫函數。 數值爲0或者字符串不是一個合法的數

原创 劍指offer:把數組排成最小的數和整數中 1 出現的個數

把數組排成最小的數 輸入一個正整數數組,把數組裏所有數字拼接起來排成一個數,打印能拼接出的所有數字中最小的一個。例如輸入數組{3,32,321},則打印出這三個數字能排成的最小數字爲321323。 分析 這題肯定要使用排序,但是要

原创 一些簡單的聚類算法

k-means 算法流程如下: 隨機選取 k 個 中心點:c1,c2,……ckc_1,c_2, ……c_kc1​,c2​,……ck​; 對每一個樣本,計算與每個中心點之間的距離,取最小的作爲它的歸類; 重新計算每個類的中心點

原创 bert

全稱:Bidirectional Encoder Representations from Transformers,即雙向 transformer的encoder 表示。 bert 的結構圖 中間的神經網絡爲 transfor

原创 一個簡單編譯器的解析:write-a-C-interpreter

前言 本文分析代碼來自 github:https://github.com/lotabout/write-a-C-interpreter/blob/master/xc.c。並非親自實現。這個一個小型的C語言編譯器,或者稱爲解釋器,