码迷,mamicode.com
首页 >  
搜索关键字:spell it right    ( 9304个结果
uva 10564
Problem FPaths through the HourglassInput:Standard InputOutput:Standard OutputTime Limit:2 SecondsIn the hourglass to the right a path is marked. A pa...
分类:其他好文   时间:2014-05-16 05:34:47    阅读次数:307
LeetCode Search in Rotated Sorted Array II
class Solution {public: bool search(int A[], int n, int target) { if (n A[mid]) { right = mid; sep = A[mid]; ...
分类:其他好文   时间:2014-05-15 09:29:52    阅读次数:177
二分查找需要注意的Bug
#include #include using namespace  std; //下面一个移位是一样的,>>相当于除去2,主要是要用right-left,否则对于大数据来说会产生溢出问题。切记 int binarySearch(int arr[],int len,int number) {     int left=0;     int right=len-1;     in...
分类:其他好文   时间:2014-05-15 07:14:38    阅读次数:272
Leetcode 树 Populating Next Right Pointers in Each Node
题意:给定一棵perfect binary tree,将它每一个节点的next指针都指向该节点右边的节点 思路:dfs 在connect一棵树的时候,需要知道这棵树的根节点和它右边的节点 1.将树的根节点和它右边的节点连接起来 2.递归地将左子树connect起来,需要知道左子树节点和右子树节点 3.递归地将右子树connect起来,需要知道右子树节点和根右边的节点的左子树节点 递归函数为: void connect(TreeLinkNode *root, TreeLinkNode *sibling) 表...
分类:其他好文   时间:2014-05-15 07:14:04    阅读次数:289
Leetcode 树 Populating Next Right Pointers in Each Node II
题意:给定一棵任意二叉树(不一定是perfect binary tree),将它每一个节点的next指针都指向该节点右边的节点 思路:bfs 这里不能用dfs了,只能用bfs bfs遍历将同一层的节点存放在同一个数组里, 然后在遍历每个数组,将前面的节点和后面的节点connect起来, 最后一个节点和NULL connect起来 需要定义一个新的struct结构,保存指向每个节点的指针和该节点所在的层 复杂度:时间O(n), 空间O( n)...
分类:其他好文   时间:2014-05-15 06:12:13    阅读次数:294
leetcode -day14 Populating Next Right Pointers in Each Node I II
1、 ?? Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate...
分类:其他好文   时间:2014-05-15 04:57:36    阅读次数:221
【LeetCode】Search a 2D Matrix
题目 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right.The first integer...
分类:其他好文   时间:2014-05-15 03:41:11    阅读次数:257
POJ 1002 487-3279
Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the Universit...
分类:其他好文   时间:2014-05-15 00:20:39    阅读次数:332
switch语句
switch 语句int x = 10switch(x) case 1:print(“sfsd”)breakcase 2:print(“dsdf”)breakdefaultprint(“right”)break
分类:其他好文   时间:2014-05-14 23:47:11    阅读次数:263
分治法--二分查找、乘方、斐波那契数
1、二分查找常见错误:死循环:循环体外的初始化条件,与循环体内的迭代步骤, 都必须遵守一致的区间规则,也就是说,如果循环体初始化时,是以左闭右开区间为边界的,那么循环体内部的迭代也应该如此.如果两者不一致,会造成程序的错误.溢出:middle=left+(right-left)/2终止条件:一般来说...
分类:其他好文   时间:2014-05-14 23:26:03    阅读次数:402
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!