
数学
文章平均质量分 76
wongson
这个作者很懒,什么都没留下…
展开
-
群里面的一道题
已知:#include using namespace std;int cnt = 1;void cal(int start){ for (int i = start; i cnt ++; cal(i+1); }}int main() { cal(0); cout return 0原创 2012-05-11 18:34:17 · 1150 阅读 · 0 评论 -
Gas Station
Gas StationThere are N gas stations along a circular route, where the amount of gas at stationi is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to trave原创 2015-08-26 20:55:39 · 516 阅读 · 0 评论 -
矩形相交判断超简单方法
设矩形A(xa1,ya1),(xa2,ya2),B(xb1,yb1),(xb2,yb2)其中:xa1xb1先看线段相交的判断:La:xa1,xa2 xa1Lb:xb1, xb2 xb1考虑对立面(只有两种情况):不相交的条件:xa2xb2由摩根律,得出相交条件:xa2>=xb1&&xa1矩形A B相交的条件为:分别在X和Y轴上的投影相交原创 2015-04-27 19:26:44 · 8288 阅读 · 0 评论 -
生成所有的BST
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3原创 2015-04-29 13:23:54 · 1171 阅读 · 0 评论 -
变位分词
static int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101}; static public int mapping(String s) { int val = 1; for原创 2015-04-24 22:44:32 · 759 阅读 · 0 评论 -
BST迭代器
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and has原创 2015-04-16 16:19:26 · 1220 阅读 · 0 评论 -
复制无向带环图
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each原创 2015-04-13 16:06:04 · 1083 阅读 · 0 评论 -
合法ip序列
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order原创 2015-04-23 17:35:14 · 790 阅读 · 0 评论 -
二分搜索
Sqrt(x) Implement int sqrt(int x).Compute and return the square root of x.原创 2015-04-01 18:20:52 · 514 阅读 · 0 评论 -
减法变加法-计算机中的补码表示
原码就是原来的表示方法反码是除符号位(最高位)外取反补码=反码+1以前学习二进制编码时,老师讲了一堆堆的什么原码啊反码啊补码啊xxxx转换啊,还有负数的表示方式啊 总是记不零清,终于从网上找到了一种比较好的讲解方式,保存再share一下,不过为了系统化讲解,又找来了一些编码的基础知识,如果只想看负数编码记忆法,请跳转到1.如果你不知道二进制怎么编码,请继续,否则请跳到2转载 2012-10-02 09:55:44 · 12906 阅读 · 2 评论 -
Searching a 2D Sorted Matrix Part II
二维整型矩阵Table [m][n]. 满足Table[i][j] ≤ Table[i][j + 1], Table[i][j] ≤ Table[i + 1][j]在此中进行查找元素。1.阶梯搜索从右上角或者左下角开始,如下图红线所示的查找13的过程bool stepWise(int mat[][N_MAX], int N, int targ翻译 2015-09-10 12:27:25 · 682 阅读 · 0 评论