Leetcode 92: Reverse Linked List II

https://leetcode.com/problems/reverse-linked-list-ii/   92. Reverse Linked List II  Total Accepted: 85657 Total Submissions: 293208 Difficulty: Medium Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note:Given m, n satisfy the following condition:1 ≤ m ≤ n ≤ length …

Leetcode 206: Reversed Linked List

https://leetcode.com/problems/reverse-linked-list/ 206. Reverse Linked List   Total Accepted: 149090 Total Submissions: 353930 Difficulty: Easy Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both?   Code (Iterative) # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # …

Leetcode 130: Surrounding regions

https://leetcode.com/problems/surrounded-regions/ 130. Surrounded Regions   Total Accepted: 64022 Total Submissions: 378153 Difficulty: Medium Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example, X X X X X O O X X …

Leetcode 216: Combination Sum III

216. Combination Sum III https://leetcode.com/problems/combination-sum-iii/ Total Accepted: 45842 Total Submissions: 115036 Difficulty: Medium Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.   Example 1: Input: k = 3, …

“file pdftex.def” not found on Mac OS

After installing MacTex, I still encountered “File pdftex.def not found” error when compiling a tex file in TexMaker/TexShop. Here is the way to solve it: Download from pdfetx-def package from https://www.ctan.org/pkg/pdftex-def Unzip Copy the unzipped folder to the texlive installation directory. Below is what I used:  sudo cp -R graphics-def /usr/local/texlive/2016/texmf-dist/  

Restricted Boltzmann Machine

In this post, I am going to share with you my understanding in Restricted Boltzmann Machine (RBM). Restricted Boltzmann Machine is a stochastic artificial neural network that learns the probability distribution of input. A stochastic artificial neural network means a structure contains a series of units with values between 0 to 1 that depend on …

Understand “Markov Chain Sampling Methods for Dirichlet Process Mixture Models”

In this post I am going to share my understanding of the paper: Markov Chain Sampling Methods for Dirichlet Process Mixture Models. In chapter 2, it introduces the basic concept of Dirichlet Process Mixture Models. In (2.1), we have: $latex y_i | \theta_i \sim F(\theta_i) \newline \theta_i | G \sim G \newline G \sim DP(G_0, \alpha)$ …