-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func twoSum(nums []int, target int) []int { | ||
result := make([]int, 0) | ||
seen := make(map[int]int) | ||
for i, v := range nums { | ||
complement := target - v | ||
comp_indx, ok := seen[complement] | ||
if ok { | ||
result = append(result, i, comp_indx) | ||
return result | ||
} | ||
_, ok = seen[v] | ||
if ! ok { | ||
seen[v] = i | ||
} | ||
} | ||
result = append(result, 9,9) | ||
return result | ||
} | ||
|
||
func main() { | ||
nums := []int{3,2,4} | ||
target := 6 | ||
answer := twoSum(nums, target) | ||
fmt.Println(answer) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module myshkins_grind_problems | ||
|
||
go 1.23.1 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Definition for a binary tree node. | ||
class TreeNode: | ||
def __init__(self, val=0, left=None, right=None): | ||
self.val = val | ||
self.left = left | ||
self.right = right | ||
|
||
class Solution: | ||
def levelOrder(self, root: TreeNode) -> list[list[int]]: | ||
level = [root] | ||
res = [] | ||
while True: | ||
temp = [] | ||
for node in level: | ||
if node.right: | ||
temp.append(node.right) | ||
if node.left: | ||
temp.append(node.left) | ||
level_values = [node.val for node in level] | ||
res.append(level_values) | ||
level = temp | ||
if len(temp) == 0: | ||
break | ||
return res | ||
|
||
root = TreeNode( | ||
val=3, | ||
left=TreeNode( | ||
val=9, | ||
left=None, | ||
right=None | ||
), | ||
right=TreeNode( | ||
val=20, | ||
left=TreeNode( | ||
val=15, | ||
left=None, | ||
right=None | ||
), | ||
right=TreeNode( | ||
val=7, | ||
left=None, | ||
right=None | ||
) | ||
) | ||
) | ||
|
||
s = Solution() | ||
print(s.levelOrder(root)) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.