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...

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 is an important data structure.There are multiple ways to implement, today we are going to talk about the most common 2 ways. ImplementationHashMapHas...

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...

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, ...

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...

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...

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...

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...

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