This file contains hidden or 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
| colorscheme evening | |
| set number | |
| set relativenumber | |
| call plug#begin() | |
| Plug 'rust-lang/rust.vim' | |
| call plug#end() |
This file contains hidden or 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
| ZSH_THEME="minimal" | |
| # Turn off all beeps | |
| unsetopt BEEP |
This file contains hidden or 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 main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "log" | |
| "os" | |
| ) | |
| func main() { |
This file contains hidden or 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
| func numIslands(grid [][]byte) int { | |
| if grid == nil { | |
| return 0 | |
| } | |
| var numOfIslands int | |
| for i := 0; i < len(grid); i++ { | |
| for j := 0; j < len(grid[0]); j++ { | |
| if grid[i][j] == '1' { |
This file contains hidden or 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
| // O(n) time, O(n) space | |
| func runningSum(nums []int) []int { | |
| if len(nums) <= 1 { return nums } | |
| var result []int // O(n) space complexity | |
| result = append(result, nums[0]) | |
| for i := 1; i < len(nums); i++ { // O(n) time complexity | |
| result = append(result, nums[i]+(result[i-1])) | |
| } | |
| return result |
This file contains hidden or 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
| type MaxHeap [][]int | |
| func (h MaxHeap) Len() int { return len(h) } | |
| func (h MaxHeap) Less(i, j int) bool { return h[i][0] > h[j][0] } | |
| func (h MaxHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } | |
| func (h *MaxHeap) Push(x interface{}) { | |
| *h = append(*h, x.([]int)) | |
| } |
This file contains hidden or 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
| func topKFrequent(nums []int, k int) []int { | |
| freqMap := make(map[int]int) | |
| for _, n := range nums { | |
| freqMap[n]++ | |
| } | |
| freqArr := make([][]int, len(nums)+1) | |
| for k, v := range freqMap { | |
| freqArr[v] = append(freqArr[v], k) | |
| } |
This file contains hidden or 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
| func isAnagram(s string, t string) bool { | |
| sCount := make([]int, 26) | |
| for _, char := range s { | |
| sCount[char-'a']++ | |
| } | |
| tCount := make([]int, 26) | |
| for _, char := range t { | |
| tCount[char-'a']++ | |
| } |
This file contains hidden or 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
| func reverseList(head *ListNode) *ListNode { | |
| curr := head | |
| var prev *ListNode | |
| for curr != nil { | |
| next := curr.Next | |
| curr.Next = prev | |
| prev = curr | |
| curr = next | |
| } |
This file contains hidden or 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
| func levelOrder(root *TreeNode) [][]int { | |
| if root == nil { | |
| return nil | |
| } | |
| q := []*TreeNode{root} | |
| var result [][]int | |
| for len(q) != 0 { | |
| size := len(q) |
NewerOlder