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
colorscheme evening | |
set number | |
set relativenumber | |
call plug#begin() | |
Plug 'rust-lang/rust.vim' | |
call plug#end() |
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
ZSH_THEME="minimal" | |
# Turn off all beeps | |
unsetopt BEEP |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { |
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
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 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 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 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 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 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 maxProfit(prices []int) int { | |
var max int | |
l, r := 0, 1 | |
for r < len(prices) { | |
if prices[l] < prices[r] { | |
max = int(math.Max(float64(max), float64(prices[r]-prices[l]))) | |
} else { | |
l = r | |
} |
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
func twoSum(nums []int, target int) []int { | |
hm := make(map[int]int) | |
for i, n := range nums { | |
if j, exists := hm[n]; exists { | |
return []int{i, j} | |
} | |
hm[target-n] = i | |
} | |
NewerOlder