发布时间:2015-03-22 16:56:29
/Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.class Point { int x; int y; Point() { x = 0; y = 0; } Point(int a, int b) { x = a; y = b; } }public class MaxPoints {public sta.........【阅读全文】
发布时间:2015-03-22 16:55:55
//Find the contiguous subarray within an array (containing at least one number) which has the largest product.////For example, given the array [2,3,-2,4],//the contiguous subarray [2,3] has the largest product = 6.public class MaximumProductSubarray {public static void main(String[] a.........【阅读全文】
发布时间:2015-03-22 16:54:56
import java.util.Arrays;//Given an unsorted array, find the maximum difference between the successive elements in its sorted form.////Try to solve it in linear time/space.////Return 0 if the array contains less than 2 elements.////You may assume all elements in the array are non-n.........【阅读全文】
发布时间:2015-03-22 16:54:07
//'?' Matches any single character.//'*' Matches any sequence of characters (including the empty sequence).////The matching should cover the entire input string (not partial).////The function prototype should be://bool isMatch(const char *s, const char *p)////Some examples://isMatch("aa.........【阅读全文】
发布时间:2015-03-22 16:53:33
//Given an unsorted array of integers, find the length of the longest consecutive elements sequence.////For example,//Given [100, 4, 200, 1, 3, 2],//The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.////Your algorithm should run in O(n) complexity.impor.........【阅读全文】