non-fast forward errors

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]
Tags: Debug

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]
Tags: Array Greedy PQ

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]

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]
Tags: Backtracking