[LeetCode] Graph Valid Tree

By definition, we know that “tree” is a acyclic, connected graph.Therefore, in this problem, we only need to check if it’s acyclic and connected. The basic...

AVL Tree and Red-Black Tree

We know that when inserting or searching nodes, the time complexity is O(h), where h denotes the height of tree. Therefore, if the tree is very skewed to one...

Tree Key Point Review

Tree is an important data structure.There are multiple ways to implement, today we are going to talk about the most common 2 ways. ImplementationHashMapHas...

[LeetCode] Binary Tree Longest Consecutive Sequence

This problem is the first of its series.The initial thought might be from each node, check the consecutive sequence starting from itself. However, this will...

[LeetCode] Repeated DNA Sequences

An intuitive solution would be traverse through the whole string,create HashMap using key of every 10-letter-long substring.But comparing 2 strings is slow, ...

[LeetCode] Bitwise Manipulation

Most Significant BitLeast Significant BitHow to clear LSBn & (n - 1) Gray CodeGray Code is a way to encode binary numbers so that between each number,the...

[LeetCode] Maximal Rectangle

At first, I thought this one will be similar to Maximal Square in 2D Array.But soon I realize this one is harder than finding squares.The solution is not bas...

[LeetCode] Largest Rectangle in Histogram

This problem is similar to Trapped Water.Initial thought will be for each bar, try to find the bounds of right and leftHowever this takes O(n^2) way too long...

How to Set Up Ionic/Cordova Environment

This tutorial is for Linux, not Mac! First, download Android Studioand extract the folder in /usr/bin execute /bin/studio.shSet ANDROID_HOME 12export A...

[LeetCode] My Calendar I

Very similar to insert intervals, too! 1234567891011121314151617181920212223242526272829class MyCalendar: def __init__(self): self.schedule = [] ...