Skip to content

Instantly share code, notes, and snippets.

name: clear-gh-cache
on:
schedule:
- cron: '0 5 * * 1' # Run at 5:00 AM every Monday
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
@japerry911
japerry911 / gcloudFunctionDeploy.yaml
Created May 21, 2022 22:39
gCloudFunctionDeploy yaml
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:alpine'
args:
- gcloud
- --quiet
- functions
- deploy
- $_FUNCTION_NAME
- --region=$_REGION
- --source=$_SRC_FOLDER
- --runtime=$_RUNTIME
@japerry911
japerry911 / PoetryDockerImg.yaml
Created May 21, 2022 22:37
installing poetry docker image
- name: 'docker.io/library/python:3.8-slim'
dir: $_SRC_FOLDER
entrypoint: bash
args:
- -c
- |
pip install --upgrade pip
pip install keyrings.google-artifactregistry-auth
pip install poetry==1.2.0a2
poetry export --without-hashes --output requirements.txt
def post_order_traverse(tree: BST, array: List[int]) -> List[int]:
if tree is not None:
post_order_traverse(tree.left, array)
post_order_traverse(tree.right, array)
array.append(tree.value)
return array
def pre_order_traverse(tree: BST, array: List[int]) -> List[int]:
if tree is not None:
array.append(tree.value)
pre_order_traverse(tree.left, array)
pre_order_traverse(tree.right, array)
return array
def in_order_traverse(tree: BST, array: List[int]) -> List[int]:
if tree is not None:
in_order_traverse(tree.left, array)
array.append(tree.value)
in_order_traverse(tree.right, array)
return array
class BST:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def remove(self, value, parent_node=None):
current_node = self
while current_node is not None:
# value is less than the current node's value look left
elif parent_node.left == current_node:
parent_node.left = current_node.left if current_node.left \
is not None else current_node.right
elif parent_node.right == current_node:
parent_node.right = current_node.left if \
current_node.left is not None else current_node.right
elif parent_node is None:
if current_node.left is not None:
current_node.value = current_node.left.value
current_node.right = current_node.left.right
current_node.left = current_node.left.left
elif current_node.right is not None:
current_node.value = current_node.right.value
current_node.left = current_node.right.left
current_node.right = current_node.right.right
else:
if current_node.left is not None and current_node.right is \
not None:
# smallest value of right subtree
current_node.value = current_node.right.get_min_value()
# remove the smallest value of right subtree since it is
# replacing the original node that we are removing
current_node.right.remove(current_node.value, current_node)