Instantly share code, notes, and snippets.

🎯
Focusing

# Yasser Sinjab ysinjab

🎯
Focusing
Created May 25, 2023 07:39 — forked from ldez/gmail-github-filters.md
Gmail and GitHub - Filters

# Gmail and GitHub

How to filter emails from GitHub in Gmail and flag them with labels.

The labels in this document are just examples.

## Pull Request

Filter Label
Created February 26, 2023 14:49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 package concatenate_test import ( "strings" "testing" ) func Concatenate(texts []string) string { s := "" for _, value := range texts {
Created December 3, 2022 08:54
66. Plus One
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution: def plusOne(self, digits: List[int]) -> List[int]: for i in range(len(digits)-1, -1, -1): if digits[i] == 9: digits[i] = 0 else: digits[i] += 1 return digits return [1] + digits
Created November 23, 2022 08:20
54. Spiral Matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: i, j = 0, 0 left, right, down, up = False, True, False, False n, m = len(matrix), len(matrix[0]) res = [] visited = set() def is_wall(i, j):
Created November 18, 2022 08:14
265. Paint House II
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution: def minCostII(self, costs: List[List[int]]) -> int: # Recursion or top-down approach # state: at any given state returns the minimum cost of painting a house i # with color k which is: costs[i][k] + minimum cost of painting a house i + 1 with not k # state variables are: # i house index
Last active November 17, 2022 05:53
256. Paint House
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution: def minCost(self, costs: List[List[int]]) -> int: # recursion # state is the current house we are painting with color c that has a cost + min of prev min # state variables are i, c # recurrence relation : dp(i, c) = cost[c] + min(dp(i + 1, c-1), dp(i + 1, c+1)) # base case: i == len(costs) return 0 # @lru_cache(None) # def dp(i, c):
Created November 16, 2022 06:12
714. Best Time to Buy and Sell Stock with Transaction Fee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution: def maxProfit(self, prices: List[int], fee: int) -> int: # top-down solution # holding_a_stock = 'HOLDING' # not_holding_any_stock = 'NOT_HOLDING' # @lru_cache(None) # def dp(i, holding_status): # if i == len(prices): # return 0
Created November 9, 2022 06:26
1143. Longest Common Subsequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution: def longestCommonSubsequence(self, text1: str, text2: str) -> int: # top down approach: function dp # state variables are (i, j) where i is index of text1 and j is index of text2 # if both carachters are equal retrun 1 # else choose the max between the two remaining from functools import lru_cache @lru_cache(maxsize=None)
Created October 7, 2022 08:13
8. String to Integer (atoi)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution(object): def myAtoi(self, s): """ :type s: str :rtype: int """ splitted = s.split(' ') for i in splitted: if not i: continue
Created October 2, 2022 21:10
210. Course Schedule II
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 class Solution(object): def findOrder(self, num_courses, prerequisites): """ :type numCourses: int :type prerequisites: List[List[int]] :rtype: List[int] """ # basically this is Kahn algorithm for topological sorting # I like it because it depends on the indegree centrality of the node degrees = collections.defaultdict(int)