I hereby claim:
- I am MorrisLaw on github.
- I am morrislaw (https://keybase.io/morrislaw) on keybase.
- I have a public key whose fingerprint is 20EB 8493 C6D3 30D0 876C 2DFF 6A12 0D78 BE12 366F
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
A = [10,2,5,7,3,22] | |
for j in xrange(1, len(A)): | |
key = A[j] | |
# Insert A[j] into the sorted sequence A[1..j-1]. | |
i = j - 1 | |
while (i > -1 and A[i] > key): | |
A[i + 1] = A[i] | |
i = i - 1 | |
A[i + 1] = key |
import com.google.gson.JsonElement; | |
import com.google.gson.JsonObject; | |
import com.google.gson.JsonParser; | |
import java.util.LinkedHashSet; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.PreparedStatement; |
func twoSum(nums []int, target int) []int { | |
if nums == nil { | |
return nil | |
} | |
for i := 0; i < len(nums); i++ { | |
for j := i+1; j < len(nums); j++ { | |
if nums[i] + nums[j] == target { | |
return []int{i, j} | |
} |
func containsDuplicate(nums []int) bool { | |
if nums == nil { | |
return false | |
} | |
set := make(map[int]bool) | |
for _, i := range nums { | |
if set[i] { | |
return true |
import "math" | |
func maxSubArray(nums []int) int { | |
if nums == nil { return 0 } | |
curr := nums[0] | |
max := curr | |
for i := 1; i < len(nums); i++ { | |
curr = int(math.Max(float64(curr + nums[i]), float64(nums[i]))) |
func intersect(nums1 []int, nums2 []int) []int { | |
count := make(map[int]int) | |
for _, n := range nums1 { | |
count[n]++ | |
} | |
var result []int | |
for _, n := range nums2 { | |
if count[n] > 0 { |
func merge(nums1 []int, m int, nums2 []int, n int) { | |
j := n-1 | |
if m == 0 { | |
for i := len(nums1)-1; i >= 0; i-- { | |
nums1[i] = nums2[j] | |
j-- | |
} | |
} | |
k := len(nums1)-1 |
/** | |
* Definition for a binary tree node. | |
* type TreeNode struct { | |
* Val int | |
* Left *TreeNode | |
* Right *TreeNode | |
* } | |
*/ | |
type Queue struct { | |
nodes []*TreeNode |
/** | |
* Definition for a binary tree node. | |
* type TreeNode struct { | |
* Val int | |
* Left *TreeNode | |
* Right *TreeNode | |
* } | |
*/ | |
type Queue struct { | |
nodes []*TreeNode |