Avatar
Gao
  • C
  • C#

see more about me on my Github profile.


Recurrence Equation

Introduction Sometimes we need to know the complexity of a recursive function, we usually use induction method (or sometimes is called substitution...


Tree Diameter

Definition The diameter of a tree is the distance of the longest path between two end nodes $\arg\max_{(u, v) \in G}d(u, v)$, where $d(u, v)$ is the...


Google Foobar Dodge The Lasers

Beatty sequence This problem require to calculate $\sum_{i=1}^{n} \lfloor i\sqrt{2} \rfloor$. We must take into consideration the precision and the...


Google Foobar Escape Pods

This problem involves solving the equivalent maximum flow problem. We can use Ford–Fulkerson algorithm with BFS to calculate the total flow. Maximum...


Google Foobar Free the Bunny Prisoners

Free the Bunny Prisoners Analysys The problem can be rearrange as follow: If you have N bunnies, and M locks, distribute M distinct keys among the...


Google Kickstart 2019 Round F Flattening

Google Kickstart 2019 Round F Flattening First, we find the major height $H_k$ from each position $i$ to each position $j$. The change is not more...


Google Kickstart 2019 Round G Shifts

Google Kickstart 2019 Round G Shifts We need to calculate the number of valid combinations that makes two guards happy. I first tried backtracking...


Google Kickstart 2019 Round G The Equation

Google Kickstart 2019 Round G The Equation The essential of the problem is to find the number $k$ that xor with each $A_i$ gives the largest number....


Google Kickstart 2019 Round G Book Reading

Google Kickstart 2019 Round G Book Reading The most challenge part of this problem is that Q and N is a very larger number. So making a nested for...