Add Two Numbers Total Accepted: 89439 Total Submissions: 437620 Difficulty: Medium You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) …
Author Archives: czxttkl
Leetcode 141: Linked List Cycle
Linked List Cycle Total Accepted: 74414 Total Submissions: 204066 Difficulty: Medium Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? https://leetcode.com/problems/linked-list-cycle/ Naive: O(N) space, O(N) time # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val …
Leetcode 282: Expression Add Operators
Expression Add Operators https://leetcode.com/problems/expression-add-operators/ Given a string that contains only digits 0-9 and a target value, return all possibilities to add operators +, -, or * between the digits so they evaluate to the target value. Examples: “123”, 6 -> [“1+2+3”, “1*2*3”] “232”, 8 -> [“2*3+2”, “2+3*2”] “00”, 0 -> [“0+0”, “0-0”, “0*0”] “3456237490”, 9191 …
How to remote access mysql via ssh
You need to let mysql listening on the whole Internet (or the IP address you want to restrict to). By default mysql only allows inbound traffic from localhost. To configure that, first you need to locate the configuration file that mysql takes mysql –help –verbose | more # You will find a paragraph like: Default …
Enable GPU for Theano
1. Install Theano http://deeplearning.net/software/theano/install.html 2. Use the following script to test Theano can work at least in CPU mode: ”’ test whether theano is using cpu or gpu ”’ from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time vlen = 10 * 30 * 768 # 10 x …
You are almost always getting significant p-value in large dataset
Recently, an exploding reproducibility research paper [1] shows that more than half of past published papers in the main psychological journals can’t be replicated to generate significance findings. This makes me dig a little further on how to conduct statistical tests. Let me show you my little experiments in `R` first. # remove(list=ls()) set.seed(19910715) n1 …
Continue reading “You are almost always getting significant p-value in large dataset”
How to to write multi-lined subscript in latex?
In latex, what is the best way to write multi-lined formula in subscript? Use `\atop`! For example, \begin{align*} P(M_n=1) =\sigma(&w_s(\sum\limits_{j_r \in T_{nr}}\vec{U_{j_r}} \cdot \vec{C_{j_r}} – \sum\limits_{j_b \in T_{nb}}\vec{U_{j_b}} \cdot \vec{C_{j_b}} ) + \\ &w_b(\sum\limits_{j_{r_1}, j_{r_2} \in T_{nr} \atop j_{r_1} \neq j_{r_2} }\left\Vert\vec{C_{j_{r_1}}} – \vec{C_{j_{r_2}}}\right\Vert^2 – \sum\limits_{j_{b_1}, j_{b_2} \in T_{nb} \atop j_{b_1} \neq j_{b_2} }\left\Vert\vec{C_{j_{b_1}}} – …
Continue reading “How to to write multi-lined subscript in latex?”
How to write multi-lined formula?
In latex, what is the best way to write multi-lined formula? Actually, the `begin/end{align*}` block supports `\\\` in it. For example, \begin{align*} P(M_n=1) =\sigma(&w_s(\sum\limits_{j_r \in T_{nr}}\vec{U_{j_r}} \cdot \vec{C_{j_r}} – \sum\limits_{j_b \in T_{nb}}\vec{U_{j_b}} \cdot \vec{C_{j_b}} ) + \\ &w_b(\sum\limits_{j_{r_1}, j_{r_2} \in T_{nr} \atop j_{r_1} \neq j_{r_2} }\left\Vert\vec{C_{j_{r_1}}} – \vec{C_{j_{r_2}}}\right\Vert^2 – \sum\limits_{j_{b_1}, j_{b_2} \in T_{nb} \atop j_{b_1} …
Minimum Description Length (MDL): a scoring function to learn Bayesian Network Structure
Bayesian Network Augmented Naive-Bayes (BAN) is an improved version of Naive-Bayes, in which every attribute may have at most one other attribute as its parent other than the class variable . For example (figure from [1]): Though BAN provides a more flexible structure compared to Naive Bayes, the structure (i.e., dependence/independence relationships between attributes) needs …
A viewer for Python Dict
Just found a beautiful viewer library that helps you view Python Dict object. Here is the code: “”” Created on Fri Feb 22 12:52:28 2013 @author: kranzth “”” from traits.api \ import HasTraits, Instance, Str, on_trait_change from traitsui.api \ import View, VGroup, Item, ValueEditor, TextEditor from copy import deepcopy class DictEditor(HasTraits): SearchTerm = Str() Object …