Skip to content

Instantly share code, notes, and snippets.

View jeffchiucp's full-sized avatar
🎯
Focusing

Jeff jeffchiucp

🎯
Focusing
View GitHub Profile
@jeffchiucp
jeffchiucp / Encrypter.java
Created August 23, 2020 05:19
Encrypter.java
import java.util.Scanner;
/*
* Create the Encrypter class here.
*/
class Encrypter {
public static String getEncryptedName(String name) {
// if (name != null){
Validator myValidator = new Validator();
@jeffchiucp
jeffchiucp / test.py
Last active July 8, 2020 22:02
test.py
def last_element(list_of_values):
return list_of_values[len(list_of_values) - 1] if list_of_values else None
@jeffchiucp
jeffchiucp / deletion_distance_base.py
Created September 27, 2019 20:22
deletion_distance_base.py
# Base case where at least one string is empty
def deletion_distance_base(str1, str2):
deletions = 0
if len(str1) == 0 or len(str2) == 0:
return max(len(str1), len(str2)) + deletions
def deletion_distance_recursive(str1, str2):
if len(str1) == 0 or len(str2) == 0:
@jeffchiucp
jeffchiucp / generateMatrix.py
Created September 27, 2019 16:47
generateMatrix.py
def generateMatrix(self, n):
"""
:type n: int
:rtype: List[List[int]]
"""
if n <= 0:
return []
matrix = [[0]*n for _ in xrange(n)]
@jeffchiucp
jeffchiucp / old_arrangement_schema.json
Created September 25, 2019 14:58
old_arrangement_schema
{
"_id": "aZ9TU0M8C",
"containers": [
{
"_id": "cJO1MLH1N",
"name": "blah",
"size": 4
},
{
"_id": "cBCXCOPV5",
@jeffchiucp
jeffchiucp / old_arrangement_schema.json
Created September 25, 2019 14:58
old_arrangement_schema
{
"_id": "aZ9TU0M8C",
"containers": [
{
"_id": "cJO1MLH1N",
"name": "blah",
"size": 4
},
{
"_id": "cBCXCOPV5",
@jeffchiucp
jeffchiucp / Arrangement.json
Created September 25, 2019 04:51
Arrangement Request Object for Post Request:
{
"_deleted": true,
"containers": [
{
"id": "string",
"name": "string",
"size": "string"
}
],
@jeffchiucp
jeffchiucp / updateBoard.py
Created September 15, 2019 22:30
updateBoard.py
class Solution:
def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]:
self.board = board
def dfs(i, j):
if i < 0 or j < 0 or i == len(board) or j == len(board[i]):
return
if self.board[i][j] not in ['E', 'M']:
return
if self.board[i][j] == 'M':
self.board[i][j] = 'X'
@jeffchiucp
jeffchiucp / findDuplicateSubtrees.py
Created September 11, 2019 13:43
findDuplicateSubtrees.py
def findDuplicateSubtrees(self, root):
def trv(root):
if not root: return "null"
struct = "%s,%s,%s" % (str(root.val), trv(root.left), trv(root.right))
nodes[struct].append(root)
return struct
nodes = collections.defaultdict(list)
trv(root)
return [nodes[struct][0] for struct in nodes if len(nodes[struct]) > 1]
yarn add v1.13.0
warning package.json: No license field
info No lockfile found.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning No license field