Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions 40 Week 02/id_301/LeetCode_242_301.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import "fmt"

func isAnagram(s string, t string) bool {
lenS := len(s)
lenT := len(t)
if lenS != lenT {
return false
}
if s == "" && t == "" {
return true
}
sliceS := []byte(s)
sliceT := []byte(t)
var charMap map[byte]int
charMap = make(map[byte]int)
for i := 0; i < lenS; i++ {
charMap[sliceS[i]]++
charMap[sliceT[i]]--
}

for _, v := range charMap {
if v != 0 {
return false
}
}
return true
}

func main() {
root := new(TreeNode)
root.Val = 1
root.Left = new(TreeNode)
root.Left.Val = 2
root.Right = new(TreeNode)
root.Right.Val = 3

fmt.Println(inorderTraversal(root))
}
26 changes: 26 additions & 0 deletions 26 Week 05/id_301/LeetCOde_17_301.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import "fmt"

func letterCombinations(digits string, path string, res *[]string) {
if len(digits) == len(path) {
*res = append(*res, path)
return
}
numMap := map[string][]string{
"2": {"a", "b", "c"},
"3": {"d", "e", "f"},
"4": {"g", "h", "i"},
"5": {"j", "k", "l"},
"6": {"m", "n", "o"},
"7": {"p", "q", "r", "s"},
"8": {"t", "u", "v"},
"9": {"w", "x", "y", "z"},
}
for _, v := range numMap[string(digits[len(path)])] {
path = path + string(v)
letterCombinations(digits, path, res)
fmt.Println(1)
path = path[:len(path)-1]
}
}
37 changes: 37 additions & 0 deletions 37 Week 05/id_301/LeetCode_1143_301.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import "fmt"

func longestCommonSubsequence(text1 string, text2 string) int {
len1 := len(text1)
len2 := len(text2)
if len1 == 0 || len2 == 0 {
return 0
}
dp := make([][]int, len1+1)
for i := 0; i <= len1; i++ {
dp[i] = make([]int, len2+1)
}
for i := 1; i <= len1; i++ {
for j := 1; j <= len2; j++ {
if text1[i-1] == text2[j-1] {
dp[i][j] = dp[i-1][j-1] + 1
} else {
dp[i][j] = max(dp[i-1][j], dp[i][j-1])
}
}
}
fmt.Println(dp)
return dp[len1][len2]
}

func max(x, y int) int {
if x > y {
return x
}
return y
}

func main() {
fmt.Println(longestCommonSubsequence("abcde", "ace"))
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.