摘要:用来计算32位的unsigned int中的1的个数, 其内部实现是根据查表法来计算的。
阅读全文
摘要:题目链接C. Dungeons and Candiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the loading of...
阅读全文
摘要:题目链接B. Andrey and Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrey needs one more p...
阅读全文
摘要:题目链接C. Artem and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArtem has an array of n po...
阅读全文
摘要:题目链接A. Borya and Hanabitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHave you ever played Hana...
阅读全文
摘要:纯属为了练习haskell, 竟然贴代码都没办法高亮。challenges/fp-update-listUpdate the values of a list with their absolute values. The input and output portions will be hand...
阅读全文
摘要:题目链接Problem discription:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Accepted Code: 1 /** 2 * Def...
阅读全文
摘要:1 create proc test 2 @result nvarchar(25) output 3 as 4 begin 5 select @result = 'haha' 6 return 1; 7 end 8 go 9 10 declare @result varc...
阅读全文
摘要:题目链接Problem discriptionGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets mus...
阅读全文
摘要:题目链接Problem discriptionGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size t...
阅读全文
摘要:题目链接Quoit DesignTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29547Accepted Submission(s): 7741...
阅读全文
摘要:题目链接Problem description:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would you...
阅读全文
摘要:题目链接Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next po...
阅读全文
摘要:题目链接题意:给出长度为n的数组,和整数elem, 要求删除数组中存在的elem,返回最终的数组长度。附上代码: 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 //...
阅读全文
摘要:题目链接题意:实现pos(x, n)功能, 其中x为double类型,n为int类型附上代码: 1 class Solution { 2 public: 3 double pow(double x, int n) { 4 // handle several particula...
阅读全文
摘要:题目链接题意: 给出 n * n的矩阵,要求将矩阵顺时针旋转90°(不使用额外空间) 1 /* 2 Basically, divide the array into 4 along the diagonals, 3 then for each element in the top ...
阅读全文
摘要:题目链接题意: 给定一棵二叉树, 判断是否为平衡二叉树, 这里的平衡二叉树指的是:每个结点的左右子树的深度之差不超过1。附上代码: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * ...
阅读全文
摘要:题目链接求二叉树最小深度,最小深度指的是:从根节点走到最近的叶子结点的最短长度附上代码: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6...
阅读全文
摘要:题目链接判断一颗二叉树是否是二叉搜索树(二叉排序树),也就是BST如果该二叉树是BST, 那么对其中序遍历,所得序列一定是单调递增的(不考虑有重复数值的情况)附上代码: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 *...
阅读全文
摘要:题目链接比赛时间没能通过==, 只能说明自己代码写的太不严谨咯!解题思想就是贪心先判断无解的情况: 1. 奇数不够,因为偶数是无法凑成奇数的 2. 偶数不够,2个奇数可以凑成一个偶数 3. 在奇数够用的情况下, 先在k-p堆中每一堆都放一个奇数, 那么剩余的奇数个数一定是个偶数,否则必定会...
阅读全文
摘要:题目链接将罗马数字转换为十进制整数。数据范围为:1~3999罗马数字由7种字母组成,按照特定规则可以组成任意正整数, 需要注意的是罗马数字中没有”0“.关于罗马数字具体可以看:这里附上代码: 1 class Solution { 2 public: 3 int romanToInt(stri...
阅读全文
摘要:题目链接求树的最大深度附上代码: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 ...
阅读全文
摘要:题目链接简单倒推附上代码: 1 class Solution { 2 public: 3 int minPathSum(vector > &grid) { 4 int n = (int)grid.size(); 5 if (n == 0) return 0; ...
阅读全文
摘要:心情极差。。。。。。。。。。。。。。。。。。无事可做,其实是没心情去做事情,只好又翻起了haskell入门记下几点,以备查询:1. 函数名首字符是不可以大写的, 而且名称中可以有单引号,这也是合法的2. if语句中else部分是不可以省略的3. 函数声明无先后顺序4. 数字5既可以是整形也可...
阅读全文
摘要:题目链接又是一个考察对链表基本操作的题目附上代码: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * Lis...
阅读全文