【问题】
Given n points
on a 2D plane, find the maximum number of points that lie on the same straight line.
【思路】
对每一个点,分别计算这个点和其他所有点构成的斜率,具有相同斜率最多的点所构成的直线,就是具有最多点的直线。
【代码】
class Point:
def __in...
分类:
编程语言 时间:
2014-06-25 19:34:29
阅读次数:
246
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
分类:
其他好文 时间:
2014-06-25 18:40:08
阅读次数:
182
【题目】
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
Note:
You may not engage in multiple transactions at the same time (i...
分类:
其他好文 时间:
2014-06-24 23:28:43
阅读次数:
223
【题目】
Given a binary tree, find the maximum path sum.
The path may start and end at any node in the tree.
For example:
Given the below binary tree,
1
/ 2 3
Return 6.
【题意】
给定一棵二叉树,找出其中路径和最大的路径,然会返回最大路径和。
本题中的路径不是从根节点到叶子节点这样的传统的路...
分类:
其他好文 时间:
2014-06-24 20:42:59
阅读次数:
268
【题目】
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). H...
分类:
其他好文 时间:
2014-06-24 19:40:53
阅读次数:
240
题目
Given a string S,
find the longest palindromic substring in S.
You may assume that the maximum length of S is
1000, and there exists one unique longest palindromic substring.
方法
...
分类:
其他好文 时间:
2014-06-24 19:36:55
阅读次数:
212
标准化表示从你的数据存储中移去数据冗余 (redundancy)的过程。如果数据库设计达到了完全的标准化,则把所有的表通过关键字连接在一起时,不会出现任何数据的复本 (repetition)。标准化的优点是明显的,它避免了数据冗余,自然就节省了空间,也对数据的一致性(consistency)提供了根...
分类:
数据库 时间:
2014-06-24 15:14:26
阅读次数:
255
Python中默认的最大递归深度是989,当尝试递归第990时便出现递归深度超限的错误:RuntimeError: maximum recursion depth exceeded in comparison简单方法是使用阶乘重现: 1 #! /usr/bin/env Python 2 3 def....
分类:
编程语言 时间:
2014-06-23 07:40:27
阅读次数:
298
题目来源:Light OJ 1272 Maximum Subset Sum
题意:选出一些数 他们的抑或之后的值最大
思路:每个数为一个方程 高斯消元 从最高位求出上三角 消元前k个a[i]异或和都能有消元后的异或和组成
消元前
k
个
a[i]
a[i]异或和都能有消元后的
异或和都能有消元后的
p
个
a[i]
a[i]的异或
的异或
保证每一列只有一个1 消元...
分类:
其他好文 时间:
2014-06-22 16:58:09
阅读次数:
231
#ifndef _LINUX_TASKS_H#define _LINUX_TASKS_H/** This is the maximum nr of tasks - change it if you need to*///最大的进程数量#define NR_TASKS 128#endif
分类:
系统相关 时间:
2014-06-20 17:29:36
阅读次数:
290