- 博客(15)
- 资源 (7)
- 收藏
- 关注
原创 299. Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t
2016-08-31 16:11:38 440
原创 389. Find the Difference
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was
2016-08-30 15:58:10 469
原创 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3
2016-08-24 19:08:37 400
原创 102. Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 2
2016-08-23 19:27:36 302
转载 C++ STL--stack/queue 的使用方法
http://www.cnblogs.com/mfryf/archive/2012/08/09/2629992.html1、stackstack 模板类的定义在头文件中。stack 模板类需要两个模板参数,一个是元素类型,一个容器类型,但只有元素类型是必要的,在不指定容器类型时,默认的容器类型为deque。定义stack 对象的示例代码如下:stack s1;sta
2016-08-23 17:56:41 270
原创 二叉树的遍历
参考自:http://blog.csdn.net/fansongy/article/details/6798278/遍历即将树的所有结点访问且仅访问一次。按照根节点位置的不同分为前序遍历,中序遍历,后序遍历。前序遍历:根节点->左子树->右子树中序遍历:左子树->根节点->右子树后序遍历:左子树->右子树->根节点例如:求下面树的三种遍历
2016-08-23 16:37:48 331
原创 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2016-08-23 14:33:59 356
原创 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?为了不另开内存,可以用快慢指针来判别,如果有环那么快指针肯定会追上慢指针;fast=fast->next->next;slow=slow->next;判
2016-08-23 09:34:30 316
原创 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".Note
2016-08-22 23:45:51 338
原创 70. Climbing Stairs
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 climb to the top?拿到题目先莫方,可以先列几个试试;
2016-08-22 10:32:02 379
原创 235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw
2016-08-22 00:57:31 404
原创 191. Number of 1 Bits (Hamming weight计算)
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 000000
2016-08-22 00:29:13 342
原创 202. Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares
2016-08-22 00:16:57 374
原创 LeetCode 231: Power of Two
Given an integer, write a function to determine if it is a power of two.很简单的题目,但是可以有多种方法解决;一,求log2(n)用换底公式可以得到double res=log10(n)/log10(2);判断res是否为零。此法可以判断各种 幂的问题代码如下:class Solution {public
2016-08-21 23:19:30 385
原创 leetcode 383. Ransom Note
class Solution {public: bool canConstruct(string ransomNote, string magazine) { map m; int len1=ransomNote.size(); int len2=magazine.size(); int icount=0;
2016-08-20 12:30:02 1146
献给CV和CG入门者之科研经验浅问细答兼与大家探讨
2014-04-24
VLFEAT_0.9.17 OpenCv Matlab接口工具
2013-10-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人