Description:
This error is faced when git cannot commit your changes to the remote repository. This may happen because your commit was lost or if someone else is trying to push to the same branch as you. This is the error you face.
```
$ git push origin master
[Read More]
621. Task Scheduler
Naive : from heapq import heappush, heappop class Solution: # time(N) space O(N) def leastInterval(self, tasks: List[str], n: int) -> int: size = len(tasks) if not n: return size # step1: count times of each task, get the task with max cnt = collections.Counter(tasks) # step2: push cnt,task into PQ...
[Read More]
187. Repeated DNA Sequences
Solution1: hash set + substring """ step1: create 2 sets for seen and repeated 10digit substring. step2: loop through whole string, until last 9 digit step3: check each substing start with i, end with i+10, if it has been seen before step4: if not seen, update seen, if yes, add...
[Read More]
1624. Largest Substring Between Two Equal Characters
""" main idea: use dictionar to get char that appeared more than once. store its index in order, get max index difference so far """ class Solution: def maxLengthBetweenEqualCharacters(self, s: str) -> int: d = collections.defaultdict(list) res = 0 flag = False for idx,ch in enumerate(s): d[ch].append(idx) for ch, li...
[Read More]
742. Closest Leaf in a Binary Tree
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def findClosestLeaf(self, root: TreeNode, k: int) -> int: """ for Binary tree, if we need to check neighbour node which...
[Read More]