## Thursday, July 30, 2015

### Leetcode: lowest common ancestor in binary tree

July 30, 2015
problem statement:
lowest common ancestor in binary tree, question No: 236

Try 4 implementations, 2 passes, but 2 failed.
write C# code:

## Tuesday, July 28, 2015

### CSS, JavaScript, Jquery learning

July 27, 2015

Basic training code for CSS, html, Jquery, Javascript from books, public internet, and other people's blog. Training basics, know concepts.

Learning a new language takes time, know syntax, memorize CSS selectors, and then, read "Head first CSS" and understand basic box model, rules, cascading rules, specificity in CSS etc.; she should have stayed more organized.

My favorite thing to do is to challenge myself, try to memorize something over 10 times and see if it will help me learn a new language, improve programming performance.

Java Script cheat sheet from book Pocket Guide To JavaScript is my favorite one to read, and practice to memorize.
Here is another one:
http://www.cheatography.com/davechild/cheat-sheets/javascript/

### SQL Server DBA, database design, and development

July 28, 2015

SQL server DBA most popular guidelines for self-learner:

1.       Database may be set up simple transaction log, so the database can be fixed size; never worry about disk space;

2.      Back up database every day; no pressure to work on live database update; certainly, reduce risk to manual update record one by one instead of update statement.

Also, the website to find the SQL performance script to do daily monitor using database mail setup, so database disk space, backup log, auto growth log, and all other activity can be helpful for every morning.

Here is her favorite site to get the SQL script:

Never too later to share her thoughts and great ideas with outside world, also her first blog about SQL server DBA experience.

### Leetcode Question No 70: climbing stairs

July 28, 2015

Problem statement:
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

The problem is most popular question in the algorithm, so I do like to spend time to find out all sorts of solution, and get myself comfortable to all kinds of ideas, and figure out which one is best, and all concerns we can have in the discussion of climbing stairs:

1. Recursion solution vs. DP problem solution (Dynamic Programming solution)
2. Time complexity solution: O(2^n) vs O(n) solution
3. The space O(N) vs O(1), in other words: array of N or 2 variable, and another tmp variable
4. The base case discussion: f(0) = 1 or f(0) =1, math question?
5. Math formula - closed form solution vs DP problem solution
6. Use Memoization DP vs. no memoization DP
7. Programming skills, how to make code easy to follow, more readable, more abstract.

The investment of time on the problem is well done. Go over 16 implementation one by one using C# programming language.

C# code:

January 3, 2016
Review the leetcode question 70, climbing stairs.
http://blog.csdn.net/kenden23/article/details/17377869
http://yucoding.blogspot.ca/2012/12/leetcode-question-15-climbing-stairs.html

http://www.cnblogs.com/springfor/p/3886576.html

http://www.cnblogs.com/springfor/p/3886576.html

http://siddontang.gitbooks.io/leetcode-solution/content/dynamic_programming/climbing_stairs.html

https://github.com/zwxxx/LeetCode/blob/master/Climbing_Stairs.cpp

## Sunday, July 26, 2015

July 26, 2015

So lucky to come cross the webpages and then start to read, great reading time:

http://www3.cs.stonybrook.edu/~rezaul/Spring-2015/CSE548/Yonghui-Wu/lecture-2-1.pdf

Competitive Programming for Solving Algorithmic Problems:
http://www3.cs.stonybrook.edu/~rezaul/CSE548-S15.html

## Saturday, July 25, 2015

July 24, 2015

### Introduction

I like to share the article talking about Google interview written in Chinese. The article is called "死理性派教你做谷歌面试题", the link is here

The experience of working on Leetcode is so challenging. I fully understand the solution but after a few days, I have no clue how it works. But there are so many good articles to read.

### Leetcode 238 in Chinese

转载上面网页最后一段.

S [ i ] = A [ 1 ] * ... * A [ i – 1 ]
T [ i ] = A [ i + 1 ] * ... * A [ n ]

## Thursday, July 23, 2015

### Leetcode 102: Binary tree level order traversal

July 23, 2015
Problem statement:
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree `{3,9,20,#,#,15,7}`,
```    3
/ \
9  20
/  \
15   7
```
return its level order traversal as:
```[
[3],
[9,20],
[15,7]
]
```
confused what `"{1,#,2,3}"` means? > read more on how binary tree is serialized on OJ.

1. Solution 1: (push extra null node in the queue to divide level)
convert it to C# code:
C# code passing leetcode online judge:
Solution 2: (using 3 variables to help queue to do BFS algorithm)
blog:
C# code:
Solution 3: DFS algorithm:
blog:
C# code:

Solution 4: using two containers for current level, next level
blog:
C# code:
https://github.com/jianminchen/BTreeLevelOrderTraversal/blob/master/BTreeLevelOrderTraversal5.cs
Solution 5: one queue and iteratively solution (单个queue的迭代解法)
blog:
C# code:
https://github.com/jianminchen/BTreeLevelOrderTraversal/blob/master/BTreeLevelOrderTraversal6.cs

Solution 6: one queue and extra node null into queue to mark end of level
blog:
C# code:
https://github.com/jianminchen/BTreeLevelOrderTraversal/blob/master/BTreeLevelOrderTraversal7.cs

## Sunday, July 19, 2015

### Leetcode 37: Sudoku Solver

July 19, 2015

Problem statement:
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character `'.'`.
You may assume that there will be only one unique solution.

Solution 1:

http://blog.csdn.net/fightforyourdream/article/details/16916985

And then, start to implement the solution using C# code:

https://github.com/jianminchen/sudokuSolver/blob/master/Program.cs

Solution 2:

http://blog.csdn.net/linhuanmars/article/details/20748761

and then, implement the solution using c# code:

https://github.com/jianminchen/sudokuSolver/blob/master/Program2.cs

Solution 3: (good workout on C# KeyValuePair class)

and then, convert C++ code to C# code from the blog:
https://github.com/yinlinglin/LeetCode/blob/master/SudokuSolver.h

Excellent code in C++, using class for node on the board. Learn a few things, fun to play with the code

C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program3.cs

solution 4:
https://github.com/jianminchen/sudokuSolver/blob/master/Program4.cs
source code from the blog:
https://github.com/xiaoxq/leetcode-cpp/blob/master/src/SudokuSolver.cpp

Solution 5:
read the blog: (Good coding! practice more based on this blog)
https://github.com/zwxxx/LeetCode/blob/master/Sudoku_Solver.cpp

and convert the C++ code to C# code, (great workout on C# LinkedList for blank nodes)

https://github.com/jianminchen/sudokuSolver/blob/master/Program5.cs

Solution 6:
http://shanjiaxin.blogspot.ca/2014/04/sudoku-solver-leetcode.html

and convert Java code to C# code, great workout on C# and logic checking "return false"

https://github.com/jianminchen/sudokuSolver/blob/master/Program6.cs

Solution 7:
blog:
http://www.jiuzhang.com/solutions/sudoku-solver/
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program7.cs

Solution 8:
Thanks for the blog's highlight line of code on back tracking; finally, I got it! My logic thinking has flaws on back tracking; extra backtracking is not a good. Minimize the back tracking, only do it when "return false". It makes sense to do that.

blog:
http://bangbingsyb.blogspot.ca/2014/11/leetcode-valid-sudoku-sudoku-solver.html
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program8.cs

Solution 10:
blog: (Excellent implementation! no extra line or number in the code! Best for memorization! Go through other solutions later. )
https://github.com/rffffffff007/leetcode/blob/master/Sudoku%20Solver.java

C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program10.cs

Also, the code written has been work on readability, learned through my favorite book reading:
http://shop.oreilly.com/product/9780596802301.do

Those favorite rules I like to learn, pick up and follow:
Big fan of DRY (Do not repeat yourself) principle, do one thing a time, break giant expression, using explaining variable or summary variable, and abstract the thing to a function, extract a subproblem to a function. The code is also modified to fit into short memory, less mental baggage to read through.

https://github.com/jordandong/myleetcodes/blob/master/SudokuSolver.cpp

https://github.com/Sayericplz/myleetcode/blob/master/isValidSudoku.cpp

BFS, using queue - try to convert it to C#
http://yucoding.blogspot.ca/2013/12/leetcode-question-sudoku-solver.html

### Leetcode: maximal rectangle

July 19, 2015

Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.

http://www.aiuxian.com/article/p-389634.html

http://www.cnblogs.com/lichen782/p/leetcode_maximal_rectangle.html

Fully understand the problem and solution, and then, spend some time to convert java code to C# code; and then, play with code, and see if I can improve the code.

## Thursday, July 16, 2015

### leetcode: longest substring without repeating characters

July 16, 2015

Problem statement:

Longest Substring Without Repeating Characters

Julia发现改写代码, 从其他语言到C#, 让她有机会快速练习写代码, 学习C#语言; 同时, 体会和其他语言的不同, 开阔眼界; 读的再多, 想法很好, 不会写代码实现, 或超过时间范围, 或写起来头痛, 太多错误, 都通过Leetcode训练, 有所提高.

Share C# code:

First blog about the same problem:

"撑死胆大的,饿死胆小的. ", 虽然是个歇后语, 但是, 这道题目, 如果只考虑抽象思维, Hashset, 不具体讨论256字符等具体内容, 确实可以10 - 15分钟写出代码. 这是Julia练习的代码, 在第一次训练几个月之后.

https://github.com/jianminchen/Leetcode_C-/blob/master/3LongestSubstringWithoutRepeating.cs

### leetcode Question No 132: palindrome 2

July 16, 2015
Problem statement:
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = `"aab"`,
Return `1` since the palindrome partitioning `["aa","b"]` could be produced using 1 cut.
Share C# code:
https://github.com/jianminchen/palindromeII/blob/master/Program.cs

January 2, 2016
Review the source code, and try to figure out the algorithm.

## Monday, July 13, 2015

### Leetcode: study time

July 14, 2015

做Leetcode题目需要选择自己熟悉的编程语言; 正好, 想提高C#的编程, 看C++的代码, 改写C#; 从Java 代码改写成C#. 现在, 题目还有很多没有看过, 想法都没有, 还会紧张. 所以, 尝试看一个人的博客, 选十几个没有做过的问题, 在几个小时内读一遍.

今天就读下面博客:

http://blog.csdn.net/fightforyourdream/article/category/1350225

http://www.lifeincode.net/category/programming/

### Leetcode: study time

July 13, 2015
Choose to read blogs with code using Java programming language. 很多题是第一次接触.

The majority vote ( more than n/3 element in an array, go through the array once or twice, get the number)
The maximum rectangle problem:
The longest increasing subsequence:
Microsoft interview question:
Review strstr leetcode question: (KMP, Boyer-Moore, Rabin-Karp algorithm)
DP problem: leetcode question

## Thursday, July 9, 2015

### ITInt5: Excel columns to integer

July 8, 2015
Problem statement:

Excel中的行列数用A~Z 26个字母表示，A, B, C, D, …, Z, AA, AB, …, AZ, BA, BB, …

Share C# code for the practice:

### ITInt5: Arithmetic Expression Evaluation

July 9, 2015

 给定一个表达式字符串，其中只包含非负整数，加法，减法以及乘法符号，例如7+3*4*5+2+4-3-1。请写程序计算该表达式的值。 提示：可以尝试使用递归算法，程序将非常简洁易写，很适用于面试场合。
https://github.com/AnnieKim/ITint5/blob/master/026_%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%B1%82%E5%80%BC.cpp

https://github.com/jordandong/myITint5/blob/master/26_Evaluation.cpp

## Monday, July 6, 2015

### Leetcode Question No. 53: Maximum subarray sum

July 6, 2015

problem statement:

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [−2,1,−3,4,−1,2,1,−5,4],
the contiguous subarray [4,−1,2,1] has the largest sum = 6.

Study the code:
http://joycelearning.blogspot.ca/2013/10/leetcode-maximum-subarray.html

1. Keyword lookup:

DP problem: Kadane's algorithm, maximum subarray sum

2. Write a program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.

January 3, 2015

Review the question.

Here is the link of C# solution:

https://github.com/jianminchen/Leetcode_C-/blob/master/53MaximumSubArray1.cs

study code:

### ITInt5: maximum boxes

July 6, 2015
Problem statement:

n块积木，每块积木有体积vol和重量weight两个属性，用二元组(vol, weight)表示。

7个积木boxes:
[(65, 100), (70, 150), (56, 90), (75, 190), (60, 95), (68, 110), (80, 12)]

(56, 90), (60, 95), (65, 100), (68, 110), (70, 150), (75, 190)

Solution: 先按照vol进行排序，题目就变成了根据weight寻找最长严格递增子序列。
Share C# practice:

### ITINT5: tree maximum path sum (I)

July 6, 2015
Problem statement:

-10
/ | \
2 3 4
/ \
5 -1
/
6
/
-1

Solution: LeetCodeBinary Tree Maximum Path Sum的扩展，这里是树，而非二叉树。
Share C# code:

February 3, 2016

work on Leetcode question 124: Binary Tree Maximum Path Sum