摘要: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: Exa 阅读全文
posted @ 2017-03-08 11:41 Hutonm 阅读(111) 评论(0) 推荐(0) 编辑
摘要: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2016-12-30 18:47 Hutonm 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = 阅读全文
posted @ 2016-12-30 18:20 Hutonm 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2016-12-30 17:54 Hutonm 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g 阅读全文
posted @ 2016-12-30 17:53 Hutonm 阅读(159) 评论(0) 推荐(0) 编辑
摘要: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul 阅读全文
posted @ 2016-12-30 14:09 Hutonm 阅读(140) 评论(0) 推荐(0) 编辑
摘要: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/ve 阅读全文
posted @ 2016-12-30 13:33 Hutonm 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5776 求是否有区间的和是m的倍数 预处理前缀和,一旦有两个数模m的值相同,说明中间一部分连续子列可以组成m的倍数。 证明:若 x % m = b 且 y % m = b,那么x可以写成x = a1 * 阅读全文
posted @ 2016-08-01 14:59 Hutonm 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 问题描述给定参数n(n为正整数),请计算n的阶乘n!末尾所含有“0”的个数。例如,5!=120,其末尾所含有的“0”的个数为1;10!= 3628800,其末尾所含有的“0”的个数为2;20!= 2432902008176640000,其末尾所含有的“0”的个数为4。计算公式这里先给出其计算公式,后 阅读全文
posted @ 2016-06-28 20:58 Hutonm 阅读(6566) 评论(0) 推荐(1) 编辑
摘要: 1 void toposort(int map[MAX][MAX],int indegree[MAX],int n) 2 { 3 int i,j,k; 4 for(i=0;i<n;i++) //遍历n次 5 { 6 for(j=0;j<n;j++) //找出入度为0的节点 7 { 8 if(indeg... 阅读全文
posted @ 2016-05-25 16:01 Hutonm 阅读(132) 评论(0) 推荐(0) 编辑