1. Pow(x, n)

    Leave a comment

    September 24, 2017 by oneOokay

    Implement pow(x, n). 不是很明白pow(x, n)到底在考什么. 首先pow(x, n)表示x的n次幂. power就是幂. 考点在于: 速度要快,不能就直接for loop单个数字相乘. power也是乘法,要用乘法的特性来提高算法效率.所以直接乘就会TLE n可以为正数也可以为负数.注意负数:Integer.MIN_VAUE:是 [ – (2的31次方)]. Integer.MAX_VALUE是[2的31次方 – 1].所以Integer.MIN_VALUE的绝对值是会大于Integer.MAX_VALUE的绝对值的. 这里某些算法会产生over flow. …
    Continue reading

  2. Find the Celebrity

    Leave a comment

    September 24, 2017 by oneOokay

    Suppose you are at a party with n people (labeled from 0 to n – 1) and among them, there …
    Continue reading

  3. Minimum Size Subarray Sum

    Leave a comment

    September 23, 2017 by oneOokay

    Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. …
    Continue reading

  4. Walls and Gates

    Leave a comment

    September 21, 2017 by oneOokay

    You are given a m x n 2D grid initialized with these three possible values. -1 – A wall or an obstacle. 0 – …
    Continue reading

  5. One Edit Distance

    Leave a comment

    September 18, 2017 by oneOokay

    Given two strings S and T, determine if they are both one edit distance apart. 杀鸡用了牛刀…写了个DP的方法,应该是写成了Edit Distance, 结果TLE了. 这题竟然磕了许久…要理清楚思路吧. One …
    Continue reading

  6. Combination Sum IV

    Leave a comment

    September 16, 2017 by oneOokay

    其他的Combination Sum Combination Sum IV Given an integer array with all positive numbers and no duplicates, find the number of …
    Continue reading

  7. TODO

    Leave a comment

    July 6, 2017 by oneOokay

    Longest Increasing Subsequence Count of Smaller Numbers After Self