Tech Interview

Some topics from either oj.leetcode.com or hackerrank:

Palindrome

  • Palindrome Number
    Is a number palindrome?
    Solution: reverse the integer and see if they equal. Pay attention to the sign
    Big-O: 0 space n time (n is the length of number)
  • Palindrome Partition I
    Find all possible ways to partition a string into palindrome substrings
    Solution: DP
    Big-O: n^2 space 2^n time (n is the length of string)
  • Palindrome Partition II
    Find the minimum number of cuts to partition a string into palindrome substrings
    Solution: Double DP. If use the previous problem, too much space and time.
    Find P[i][j] s.t. P[i][j] is true if s[i:j] is palindrome. D[i] is the mincut
    of s[i:].
    Big-O: n^2 space n^2 time (n is the length of string)
  • Palindrome Index
    Find the index in the string which if removed, makes the string palindrome
    Solution: TODO
  • Longest Palindrome Substring
    Solution: We can use the DP in “Pal Part II”, which will have O(n^2) big-O. Or we can use manacher’s algorithm in O(n).

Binary Tree