码迷,mamicode.com
首页 >  
搜索关键字:definition    ( 2735个结果
关于全局变量的一个问题
一#include//int a;//a=10;int a=10;int main(){ printf("%d",a); getchar(); return 0;}会有一个警告:数据定义没有类型或者存储类型warning: data definition has no type or stor...
分类:其他好文   时间:2014-12-16 09:58:00    阅读次数:197
Leetcode-Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.Solution: 1 /** 2 * Definition for a point. 3 ...
分类:其他好文   时间:2014-12-16 06:30:33    阅读次数:249
leetcode Insertion Sort List
利用插入排序,对链表进行排序。插入排序点here。居然初次想用unordered map来存每个节点,然后根据下标就可以访问了,再更新下班,也就是n方的方法了。但是不知为什么超时了。插入排序不就是n方吗。/** * Definition for singly-linked list. * struc...
分类:其他好文   时间:2014-12-15 23:26:51    阅读次数:194
Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. /** * Definition for binary tree ...
分类:其他好文   时间:2014-12-15 21:52:22    阅读次数:124
算法 二叉树的各种遍历
二叉树的遍历方式基本就是前序遍历,中序遍历,后序遍历和层次遍历。从代码的角度来说,前三种最简单的就是用递归了,代码会非常简洁。但是递归有一个缺陷,就是当二叉树的节点非常多的时候,层次深的递归会不停的进行程序的压栈和出栈操作,效率比较低。这里就不写递归算法了,只写四种遍历的非递归算法。 先定义二叉树的节点如下: /**  * Definition for binary tree  * pub...
分类:编程语言   时间:2014-12-15 13:47:08    阅读次数:305
Leetcode: Reverse Nodes in k-Group
链表的倒转, /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ /** * Definition for singly-link...
分类:其他好文   时间:2014-12-14 00:46:14    阅读次数:193
leetcode Binary Tree Preorder Traversal
实现前序遍历。可参见中序遍历Binary Tree Inorder Traversal递归:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode...
分类:其他好文   时间:2014-12-13 23:12:09    阅读次数:189
leetcode[145] Binary Tree Postorder Traversal
实现后序遍历递归:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(...
分类:其他好文   时间:2014-12-13 23:07:58    阅读次数:165
leetcode Linked List Cycle II
给定一个链表,如果有环,返回环的起点,如果没环,则返回空指针。法一:unordered_set存做过的节点,一旦出现重复,那么它就是起点了。O(n)空间/** * Definition for singly-linked list. * struct ListNode { * int val...
分类:其他好文   时间:2014-12-13 16:27:02    阅读次数:222
leetcode Linked List Cycle
判断链表中有没有环。一个指针跑一次,一个指针跑两次,相遇就是有环/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x...
分类:其他好文   时间:2014-12-12 22:11:59    阅读次数:162
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!