Instantly share code, notes, and snippets.

# jiankuang

Last active October 19, 2022 20:48
Data Structures and Algorithms

# Binary Tree

## Traverse a Tree

``` // Definition for a binary tree node.
class TreeNode {
val: number
left: TreeNode | null
right: TreeNode | null
constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {
this.val = (val===undefined ? 0 : val)```
Last active March 17, 2017 16:52
Python Data Structures and Algorithms
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
 def array_left_rotation(a, n, k): if n == k * 2: for i in range(k): a[i+k], a[i] = a[i], a[i+k] else: temp = a[0] i = 0 while True: if i+k < n: a[i] = a[i+k]
Last active March 17, 2017 15:18
Python snippets

`split` Function

``````>>> str = "Hello,world,how,are,you"
>>> str.split(",")
['Hello', 'world', 'how', 'are', 'you']
>>> str.split(",")[0]
'Hello'
>>> str.split(",")[1]
'world'
&gt;&gt;&gt; str.split(",", 1)
``````
Last active November 29, 2016 19:25

SSH
`gcloud compute ssh jian_kuang@compute-engine-instance-with-bigtable-access`
Copy
`gcloud compute copy-files Anaconda2-4.2.0-Linux-x86_64.sh jian_kuang@genia-datalab-compute:Anaconda2-4.2.0-Linux-x86_64.sh --zone us-central1-b`

Last active July 6, 2016 06:52
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
 # import mysql tables into HDFS using sqoop sqoop import-all-tables --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera # import mysql tables into hive using sqoop sqoop import-all-tables --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --hive-import --create-hive-table
Last active June 4, 2016 01:48
D3 Layout Tree 2
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

Last active May 31, 2016 18:55
D3 Layout Bubble
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

Last active May 29, 2016 19:49
D3 Layout Pack
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

Last active May 29, 2016 18:52
D3 Layout Tree
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

Last active May 29, 2016 17:04
D3 Layout Pie Chart
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