note-Recursion and DP

  • Bottom-Up approach:
    more intuitive. The key is to think about how to build solution for one case off of the previous case

  • Top-Down approach:
    how to divide the problem for case N into subproblems, be careful of overlap between cases.

Readmore

46. Permutations

Problem description:

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Readmore

43. Multiply Strings

Problem description:

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.

Readmore

41. First Missing Positive

Problem description:

Given an unsorted integer array, find the smallest missing positive integer.

Readmore

35. Search Insert Position

Problem description:

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

Readmore

27. Remove Element

Problem description:

Given an array nums and a value val, remove all instances of that value in-place and return the new length.

Readmore

26. Remove Duplicates from Sorted Array

Problem description:

Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.

Readmore

25. Reverse Nodes in k-Group

Problem description:

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

Readmore

note-Priority_Queue

Initialize of customize priority queue:

  1. define a struct of compare function.
  2. note the init method of pq.

Readmore

22. Generate Parentheses

Problem description:

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Readmore