Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.
[Read More]
LC146 LRU Cache
time O(N) space O(N)
```python
class LRUCache:
# data structure queue, store key and value
def init(self, capacity: int):
self.capacity = capacity
self.queue = deque()
[Read More]
LC69 Sqrt(x)
class Solution: #time O(lgN) spoace O(1) # main idea: binary search def mySqrt(self, x: int) -> int: l,r = 0,x while l <= r: # add equal to consider edge case 0, 1 mid = l + (r-l)//2 if mid**2 <= x< (mid+1)**2: return mid elif x < mid**2: r...
[Read More]
LC287 Find the Duplicate Number Linked List
Problem Decription
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.
[Read More]