Here are the solutions for the remaining problems on the list:
Approach: Iteratively reverse the pointers of the linked list nodes.
| Hi = (name) => { | |
| x = Object.create(Hi.prototype); | |
| x.name = name | |
| return x; | |
| } | |
| Hi.prototype = { | |
| name: null, | |
| greet: function () { | |
| return `Hello ${this.name}`; |
| """ | |
| Input | |
| s = | |
| "pineapplepenapple" | |
| wordDict = | |
| ["apple","pen","applepen","pine","pineapple"] | |
| """ | |
| # This works |
| # top-down: Larger Number TLE | |
| class Solution: | |
| def minimumTotal(self, triangle: List[List[int]]) -> int: | |
| if len(triangle) == 1: | |
| return triangle[0][0] | |
| res = tuple() | |
| level = 0 | |
| curr_list = triangle[level] | |
| next_level = level + 1 |
| # This is one way | |
| class Solution: | |
| def fourSum(self, nums: List[int], target: int) -> List[List[int]]: | |
| nums.sort() | |
| result = [] | |
| for idx, num in enumerate(nums): | |
| for res3list in self.threeSum(nums[idx+1:], target-num): | |
| if [num] + res3list not in result: | |
| result += [[num] + res3list] | |
| return result |
| # naive solution | |
| class Solution: | |
| POS_NUM = 1000 | |
| def removeDuplicates(self, nums: List[int]) -> int: | |
| start = 0 | |
| n = len(nums) | |
| end = n - 1 | |
| for start in iter(lambda: start, end): | |
| if start > end: | |
| break |
| NATO_BAG = { | |
| 'A': 'Alpha', | |
| 'B': 'Bravo', | |
| 'C': 'Charlie', | |
| 'D': 'Delta', | |
| 'E': 'Echo', | |
| 'F': 'Foxtrot', | |
| 'G': 'Golf', | |
| 'H': 'Hotel', | |
| 'I': 'India', |
| # Definition for a binary tree node. | |
| # | |
| # defmodule TreeNode do | |
| # @type t :: %__MODULE__{ | |
| # val: integer, | |
| # left: TreeNode.t() | nil, | |
| # right: TreeNode.t() | nil | |
| # } | |
| # defstruct val: 0, left: nil, right: nil | |
| # end |
| class Solution: | |
| def subsets(self, nums: List[int]) -> List[List[int]]: | |
| def do_generate(result, slate, subset): | |
| result += [slate] | |
| for idx, num in enumerate(subset): | |
| new_subset = subset[idx+1:] | |
| do_generate(result, slate + [num], new_subset) | |
| return result | |
| return do_generate([], [], nums) | |
| def find_combinations(n, k): | |
| """ | |
| Args: | |
| n(int32) | |
| k(int32) | |
| Returns: | |
| list_list_int32 | |
| """ | |
| array = list(range(1,n+1)) | |
| result = set() |