Instantly share code, notes, and snippets.

# Desolve

• Sort options
Created Jan 24, 2020
0116 Populating Next Right Pointers in Each Node
View 0116 Populating Next Right Pointers in Each Node.java
 /* // Definition for a Node. class Node { public int val; public Node left; public Node right; public Node next; public Node() {}
Created Jan 24, 2020
0116 Populating Next Right Pointers in Each Node
View 0116 Populating Next Right Pointers in Each Node.py
 """ # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next """ class Solution:
Created Jan 14, 2020
0091 Decode Ways
View 0091 Decode Ways.java
 class Solution { public int numDecodings(String s) { if (s.length() == 0) return 0; int l = s.length(); int dp[] = new int[l+1]; dp[0] = 1; // Empty string dp[1] = s.charAt(0) != '0' ? 1 : 0; char prev = '0', curr = s.charAt(0); for (int i = 2; i <= l; ++i) { prev = curr;
Created Jan 14, 2020
0091 Decode Ways
View 0091 Decode Ways.py
 class Solution: def numDecodings(self, s: str) -> int: if not s: return 0 l = len(s) dp = [0] * (l+1) dp[0], dp[1] = 1, 1 if s[0] != "0" else 0 prev, curr = "0", s[0] for i in range(2, l + 1): prev = curr curr = s[i-1]
Created Jan 8, 2020
0086 Partition List
View 0086 Partition List.java
 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode partition(ListNode head, int x) {
Created Jan 8, 2020
0086 Partition List
View 0086 Partition List.py
 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def partition(self, head: ListNode, x: int) -> ListNode: d1, d2 = ListNode(0), ListNode(0) ite = [d1, d2]
Created Jan 6, 2020
 class Solution: def checkIP(self, s: str, res: List[str], i: int, cnt: int, cur: str) -> None: if len(s) - i < 4 - cnt: return if cnt == 3: if len(s) - i <= 3: if s[i] != "0" and int(s[i:]) <= 255 or s[i:] == "0": cur += s[i:] res.append(cur) else: j = 1
Created Jan 6, 2020