LeetCode
CV小徐
CV硕士,兴趣点:计算机视觉 Deep Learning,酷爱编程,精通Python、Linux,Caffe
展开
-
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 · 446 阅读 · 0 评论 -
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 · 379 阅读 · 0 评论 -
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 · 291 阅读 · 0 评论 -
C++ STL--stack/queue 的使用方法
http://www.cnblogs.com/mfryf/archive/2012/08/09/2629992.html 1、stack stack 模板类的定义在头文件中。 stack 模板类需要两个模板参数,一个是元素类型,一个容器类型,但只有元素类型是必要 的,在不指定容器类型时,默认的容器类型为deque。 定义stack 对象的示例代码如下: stack s1; sta转载 2016-08-23 17:56:41 · 255 阅读 · 0 评论 -
二叉树的遍历
参考自:http://blog.csdn.net/fansongy/article/details/6798278/ 遍历即将树的所有结点访问且仅访问一次。按照根节点位置的不同分为前序遍历,中序遍历,后序遍历。 前序遍历:根节点->左子树->右子树 中序遍历:左子树->根节点->右子树 后序遍历:左子树->右子树->根节点 例如:求下面树的三种遍历原创 2016-08-23 16:37:48 · 314 阅读 · 0 评论 -
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 · 336 阅读 · 0 评论 -
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 · 300 阅读 · 0 评论 -
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 · 319 阅读 · 0 评论 -
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 · 365 阅读 · 0 评论 -
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 · 376 阅读 · 0 评论 -
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 · 320 阅读 · 0 评论 -
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 · 354 阅读 · 0 评论 -
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 · 1130 阅读 · 0 评论 -
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 · 367 阅读 · 0 评论 -
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 · 426 阅读 · 0 评论 -
205. Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with anot原创 2016-09-08 09:39:55 · 369 阅读 · 0 评论