Posts

Showing posts from February, 2018

Completed the LeetCode problem #36 - Validate Sudoku

https://leetcode.com/problems/valid-sudoku/description/ At first "446 / 501  test cases passed.", after using Console.Write output the whole test case and help me to debug the issue. Bug was found and fixed.

Completed the LeetCode problem #10 - Regular Express Matching

https://leetcode.com/problems/regular-expression-matching/description/ Use the Recursion method, so the performance, hurt a bit.

Completed LeetCode problem #4 - Median of Two Sorted Array

https://leetcode.com/problems/median-of-two-sorted-arrays/description/

Completed LeetCode problem 235 - Common Ancestor of Binary Search Tree

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/description/

Completed LeetCode problem #236 - Common Ancestor for Binary Tree

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/description/ More information could be found here https://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-tree-set-2-using-parent-pointer/

Completed LeetCode question #22 - Generate Parentheses

https://leetcode.com/problems/generate-parentheses/description/

Completed Leetcode #141 - Linked List Cycle

https://leetcode.com/problems/linked-list-cycle/description/

Completed LeetCode problem #124 - Binary Tree Max Path Sum

https://leetcode.com/problems/binary-tree-maximum-path-sum/description/ They made the problem more tricky by allowing negative Node Value and two leg "path extensions"

Completed LeetCode problem #104-Max Dept of Binary Tree

https://leetcode.com/problems/maximum-depth-of-binary-tree/description/ Walk in the park...

Completed the LeetCode problem #96 - Unique BST

https://leetcode.com/problems/unique-binary-search-trees/description/ public class Solution {     int[] table = new int[200];     public int NumTrees(int n) {                 for (int i=0; i<200; i++)             table[i]=-1;         table[0]=1; table[1]=1;         return catalan(n);     }         int catalan(int n) {         int res = 0;         int n1=0; int n2=0;                 // Base case         if (n <= 1) {             return 1;         }                 if(table[n]!=-1)             return table[n];                 for (int i = 0; i ...

Completed LeetCode question #98-Validate Binary Search Tree

https://leetcode.com/problems/validate-binary-search-tree/description/

Completed LeeCode problem 102-Binary Tree Level Travesal

https://leetcode.com/problems/binary-tree-level-order-traversal/description/

Completed LeetCode question #94 - Binary Tree Inorder Traversal

https://leetcode.com/problems/binary-tree-inorder-traversal/description/

Completed LeetCode problem #3 - Longest substring without repeating characters

https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ Finished the problem with best performance.

Completed LeetCode question #20- valid parentheses

https://leetcode.com/problems/valid-parentheses/description/ Their bloody test case used test string more than 1000 characters long!

Completed the LeetCode #2 adding two numbers

https://leetcode.com/problems/add-two-numbers/discuss/?page=72 But failing one of its test cases, tested the same test case locally but succeeded! So you cannot really believe the LeetCode online judge. After more digging, it turned out the test case they put together included value outside the range of the LONG data type, you have implemented addition without using the addition of integers!!!!!

Completed the LeetCode question #1-Two Sum

Started with Jagged Array solution failed some made up test cases-due to Memory Limit Exceeded . Only passed the test cases after removing the usage of the Jagged Array. Doh. https://leetcode.com/problems/two-sum/description/

Tackled the problem #147 of LeetCode - InsertionSort LinkedList

https://leetcode.com/problems/insertion-sort-list/description/

Worked out the LeetCode #51- N Queens(8 Queens)

https://leetcode.com/problems/n-queens/description/

Worked on LeetCode question #365 - Water and Jug

https://leetcode.com/problems/water-and-jug-problem/description/ Time Exceeded Limit on test case " 22003, 31237, 1"... These guys obviously tried too hard to make people's submission fail.

Worked on the LeetCode question #121 - buy sell stock once, ran into this one before.

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/