自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

成为一个合格的IT工作者

从基础开始学习,全方面塑造自己的技能树

  • 博客(67)
  • 收藏
  • 关注

原创 二叉树的中序遍历(lintcode)(递归和非递归)

题目来源:lintcode原题链接:二叉树的中序遍历题目:给出一棵二叉树,返回其节点值的后序遍历。您在真实的面试中是否遇到过这个题? Yes样例给出一棵二叉树 {1,#,2,3}, 1 \ 2 / 3返回 [3,2,1]挑战你能使用非递归实现么?

2015-11-19 22:04:59 2452

原创 链表求和(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/add-two-numbers/题目:你有两个用链表代表的整数,其中每个节点包含一个数字。数字存储按照在原来整数中相反的顺序,使得第一个数字位于链表的开头。写出一个函数将两个整数相加,用链表形式返回和。您在真实的面试中是否遇到过这个题? 

2015-11-11 22:25:09 3605

原创 x的平方根(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/sqrtx/题目:实现 int sqrt(int x) 函数,计算并返回 x 的平方根。您在真实的面试中是否遇到过这个题? Yes样例sqrt(3) = 1sqrt(4) = 2sqrt(5) = 2

2015-11-11 19:47:10 2808 2

原创 Binary Tree Level Order Traversal II(LeetCode)

题目来源:leetcode原题地址:https://leetcode.com/problems/binary-tree-level-order-traversal-ii/题目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, fro

2015-11-10 21:17:34 397

原创 Merge Intervals(LeetCode)

题目来源:LeetCode原题地址:https://leetcode.com/problems/merge-intervals/题目:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18]

2015-11-09 22:17:53 395

原创 二叉树的最大深度(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/maximum-depth-of-binary-tree/题目:给定一个二叉树,找出其最大深度。二叉树的深度为根节点到最远叶子节点的距离。您在真实的面试中是否遇到过这个题? Yes样例给出一棵如下的二叉树: 1

2015-11-05 12:35:34 1677

原创 把排序数组转换为高度最小的二叉搜索树(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/convert-sorted-array-to-binary-search-tree-with-minimal-height/题目:给一个排序数组(从小到大),将其转换为一棵高度最小的排序二叉树。样例给出数组 [1,2,3,4,5,6,7],

2015-11-05 11:49:59 2195

原创 子树(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/subtree/#题目:有两个不同大小的二进制树: T1 有上百万的节点; T2 有好几百的节点。请设计一种算法,判定 T2 是否为 T1的子树。您在真实的面试中是否遇到过这个题? Yes样例下面的例子中 T2 是 T1 的

2015-11-05 11:23:47 832

原创 主元素(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/majority-number/题目:给定一个整型数组,找出主元素,它在数组中的出现次数严格大于数组元素个数的二分之一。您在真实的面试中是否遇到过这个题? Yes样例给出数组[1,1,1,1,2,2,2],返回 1

2015-10-30 15:38:46 1225

原创 合并排序数组(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/merge-sorted-array-ii/题目:合并两个排序的整数数组A和B变成一个新的数组。您在真实的面试中是否遇到过这个题? Yes样例给出A=[1,2,3,4],B=[2,4,5,6],返回 [1,2,2,3,4,4,5

2015-10-30 15:13:22 4271

原创 加一(LintCode)

题目来源:LintCode原题地址: http://www.lintcode.com/zh-cn/problem/plus-one/题目:给定一个非负数,表示一个数字数组,在该数的基础上+1,返回一个新的数组。该数字按照大小进行排列,最大的数在列表的最前面。您在真实的面试中是否遇到过这个题? Yes样例给定 [1,2,3] 表示

2015-10-30 14:55:19 1514

原创 二进制求和(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/add-binary/题目:给定两个二进制字符串,返回他们的和(用二进制表示)。您在真实的面试中是否遇到过这个题? Yes样例a = 11b = 1返回 100难度

2015-10-30 14:46:17 1813

原创 合并两个排序链表(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/merge-two-sorted-lists/题目:将两个排序链表合并为一个新的排序链表您在真实的面试中是否遇到过这个题? Yes样例给出 1->3->8->11->15->null,2->null, 返回1->2->3->

2015-10-27 19:10:40 362

原创 两个字符串是变位词

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/two-strings-are-anagrams/题目:写出一个函数 anagram(s, t) 去判断两个字符串是否是颠倒字母顺序构成的您在真实的面试中是否遇到过这个题? Yes样例给出 s="abcd",t="dcab"

2015-10-27 17:07:13 786

原创 链表倒数第n个节点(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/nth-to-last-node-in-list/题目:找到单链表倒数第n个节点,保证链表中节点的最少数量为n。您在真实的面试中是否遇到过这个题? Yes样例给出链表 3->2->1->5->null和n = 2,返回倒数第

2015-10-27 16:43:40 318

原创 删除元素(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/remove-element/题目:给定一个数组和一个值,在原地删除与值相同的数字,返回新数组的长度。元素的顺序可以改变,并且对新的数组不会有影响。您在真实的面试中是否遇到过这个题? Yes样例给出一个数组 [0,4,4,0

2015-10-27 16:33:55 957

原创 删除链表中倒数第n个节点(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/remove-nth-node-from-end-of-list/题目:给定一个链表,删除链表中倒数第n个节点,返回链表的头节点。您在真实的面试中是否遇到过这个题? Yes样例给出链表1->2->3->4->5-

2015-10-27 16:03:53 2822

原创 颠倒整数(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/reverse-integer/#题目:将一个整数中的数字进行颠倒,当颠倒后的整数溢出时,返回 0 (标记为 32 位整数)。您在真实的面试中是否遇到过这个题? Yes样例给定 x = 123,返回 321给定 x =

2015-10-27 15:38:42 2755

原创 奇偶分割数组(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/partition-array-by-odd-and-even/题目:分割一个整数数组,使得奇数在前偶数在后。您在真实的面试中是否遇到过这个题? Yes样例给定 [1, 2, 3, 4],返回 [1, 3, 2, 4]。

2015-10-26 22:40:07 2147

原创 在O(1)时间复杂度删除链表节点(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/delete-node-in-the-middle-of-singly-linked-list/题目:给定一个单链表中的表头和一个等待被删除的节点(非表头或表尾)。请在在O(1)时间复杂度删除该链表节点。并在删除该节点后,返回表头。您在真实的面试中是否

2015-10-26 22:20:04 975

原创 报数(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/count-and-say/题目:报数指的是,按照其中的整数的顺序进行报数,然后得到下一个数。如下所示:1, 11, 21, 1211, 111221, ...1 读作 "one 1" -> 11.11 读作 "two 1s" -> 2

2015-10-26 22:05:50 908 1

原创 最后一个单词的长度(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/length-of-last-word/#题目:给定一个字符串, 包含大小写字母、空格' ',请返回其最后一个单词的长度。如果不存在最后一个单词,请返回 0 。您在真实的面试中是否遇到过这个题? Yes样例给定 s = 

2015-10-26 17:03:23 1633 2

原创 岛屿的个数(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/number-of-islands/题目:给一个01矩阵,求不同的岛屿的个数。0代表海,1代表岛,如果两个1相邻,那么这两个1属于同一个岛。我们只考虑上下左右为相邻。您在真实的面试中是否遇到过这个题? Yes样例在矩阵:

2015-10-25 18:51:56 1528

原创 空格替换(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/space-replacement/题目:设计一种方法,将一个字符串中的所有空格替换成 %20 。你可以假设该字符串有足够的空间来加入新的字符,且你得到的是“真实的”字符长度。您在真实的面试中是否遇到过这个题? Yes样例对于字符串"Mr

2015-10-25 18:08:28 1466

原创 字符大小写排序(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/sort-letters-by-case/题目:给定一个只包含字母的字符串,按照先小写字母后大写字母的顺序进行排序。您在真实的面试中是否遇到过这个题? Yes样例给出"abAcD",一个可能的答案为"acbAD"注意小写

2015-10-25 15:32:43 2928

原创 有效的括号序列(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/valid-parentheses/题目:给定一个字符串所表示的括号序列,包含以下字符:'(', ')', '{', '}', '[' and ']', 判定是否是有效的括号序列。您在真实的面试中是否遇到过这个题? Yes样例括号必须依照 

2015-10-25 14:20:52 3180

原创 Swap Nodes in Pairs(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/swap-nodes-in-pairs/题目:Given a linked list, swap every two adjacent nodes and return its head.您在真实的面试中是否遇到过这个题? Yes样例Giv

2015-10-25 13:55:25 473

原创 最长单词(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/longest-words/题目:给一个词典,找出其中所有最长的单词。您在真实的面试中是否遇到过这个题? Yes样例在词典{ "dog", "google", "facebook", "internationalizat

2015-10-25 12:35:37 1564

原创 最长上升连续子序列(LintCode)

题目来源:LintCode原题地址:http://www.lintcode.com/zh-cn/problem/longest-increasing-continuous-subsequence/题目:最长上升连续子序列给定一个整数数组(下标从 0 到 n-1, n 表示整个数组的规模),请找出该数组中的最长上升连续子序列。(最长上升连续子序列可

2015-10-25 11:52:34 1397

原创 [C++]Kth Smallest Element in a BST 在一个二叉排序树中找第k小的元素

leetcode 原题:https://leetcode.com/problems/kth-smallest-element-in-a-bst/Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may

2015-08-29 22:12:56 635

原创 [C++]Remove Linked List Elements 删除链表中的元素

leetcode 原题链接:https://leetcode.com/problems/remove-linked-list-elements/Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 -

2015-08-27 21:23:11 1866

原创 [C++]ZigZag Conversion 之字形转换

leetcode 原题链接:https://leetcode.com/problems/zigzag-conversion/The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this patt

2015-08-25 21:24:59 531

原创 [C++]Reverse Integer整数翻转

leetcode 原题链接:https://leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321简要分析:此题并不难,但是要注意几个点,比如负数翻转之后还是负数,

2015-08-24 12:43:00 1355

原创 [C++]Excel Sheet Column Title

leetcode 原题链接:https://leetcode.com/problems/excel-sheet-column-title/Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A

2015-08-24 11:29:18 502

原创 [C++]Remove Duplicates from Sorted List 从已排序的链表中移除重复元素

leetcode 原题链接:https://leetcode.com/problems/remove-duplicates-from-sorted-list/ps: 这也是前两天腾讯电面我的一道题,虽然思路对了,但是白板写的程序,把指针箭头引用写成(.)应用了,也不知道还有没有二面,/(ㄒoㄒ)/~~Given a sorted linked list, delete al

2015-08-23 20:35:11 529

原创 [C++]Implement strStr() 找到子字符串第一次出现的位置

leetcode 原题链接:https://leetcode.com/problems/implement-strstr/Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.简要翻

2015-08-23 20:14:19 2447

原创 [C++]Merge Two Sorted Lists 归并两个排序的链表

leetcode 原题链接:https://leetcode.com/problems/merge-two-sorted-lists/Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first

2015-08-23 20:08:04 478

原创 [C++] String to Integer (atoi)

leetcode 原题链接:https://leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a chall

2015-08-21 13:14:49 1382

原创 [C++]Valid Palindrome 有效回文

leetcode 原题链接:https://leetcode.com/problems/valid-palindrome/Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A

2015-08-21 11:02:46 1000

原创 [C++]Rotate Array 旋转数组

leetcode 原题链接:https://leetcode.com/problems/rotate-array/Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated t

2015-08-21 10:06:42 2536

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除