
Pow(x, n)
Leave a commentSeptember 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 
Find the Celebrity
Leave a commentSeptember 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 
Minimum Size Subarray Sum
Leave a commentSeptember 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 
Walls and Gates
Leave a commentSeptember 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 
One Edit Distance
Leave a commentSeptember 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 
Combination Sum IV
Leave a commentSeptember 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 
TODO
Leave a commentJuly 6, 2017 by oneOokay
Longest Increasing Subsequence Count of Smaller Numbers After Self