-
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
1 parent
9cbfd0f
commit 92e3e49
Showing
5 changed files
with
77 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,10 @@ | ||
package main | ||
|
||
type Node struct { | ||
Val int | ||
Next *Node | ||
} | ||
|
||
func addTwoNumbers(l1 *Node, l2 *Node) *Node { | ||
|
||
} |
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,21 @@ | ||
package main | ||
|
||
import "strconv" | ||
|
||
func countBits(n int) []int { | ||
res := []int{} | ||
|
||
for i := 0; i <= n; i++ { | ||
binary := strconv.FormatInt(int64(i), 2) | ||
|
||
count := 0 | ||
for _, v := range binary { | ||
if v == '1' { | ||
count++ | ||
} | ||
} | ||
res = append(res, count) | ||
} | ||
|
||
return res | ||
} |
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,15 @@ | ||
package main | ||
|
||
func revertseList(head *ListNode) *ListNode { | ||
current := head | ||
|
||
var prev *ListNode = nil | ||
|
||
for current != nil { | ||
next := current.Next | ||
current.Next = prev | ||
prev = current | ||
current = next | ||
} | ||
return prev | ||
} |
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,10 @@ | ||
function countBits(n: number): number[] { | ||
let res: number[] = [] | ||
|
||
for (let i = 0; i <= n; i++) { | ||
const binary = i.toString(2) | ||
res.push(binary.split('').filter((x) => x === '1').length) | ||
} | ||
|
||
return res; | ||
}; |
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,21 @@ | ||
class ListNode { | ||
val: number; | ||
next: ListNode | null; | ||
|
||
constructor(val?: number, next?: ListNode | null) { | ||
this.val = val === undefined ? 0 : val; | ||
this.next = next === undefined ? null : next; | ||
} | ||
} | ||
|
||
function reverseList(head: ListNode | null): ListNode | null { | ||
let prev: ListNode | null = null; | ||
let current = head; | ||
while (current) { | ||
let next = current.next; | ||
current.next = prev; | ||
prev = current; | ||
current = next; | ||
} | ||
return prev; | ||
} |