Fork me on GitHub

08 2015 档案

摘要:题目:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is gr... 阅读全文
posted @ 2015-08-31 15:57 __Neo 阅读(170) 评论(0) 推荐(0) 编辑
摘要:题目:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, r... 阅读全文
posted @ 2015-08-31 15:30 __Neo 阅读(109) 评论(0) 推荐(0) 编辑
摘要:题目:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl... 阅读全文
posted @ 2015-08-31 10:04 __Neo 阅读(477) 评论(0) 推荐(0) 编辑
摘要:题目:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".提示:此题我的第一反应是把输入的两个字符串转化为数字,相加以后再把结果转化为二进制输出,... 阅读全文
posted @ 2015-08-29 16:45 __Neo 阅读(135) 评论(0) 推荐(0) 编辑
摘要:题目:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word ... 阅读全文
posted @ 2015-08-28 15:36 __Neo 阅读(101) 评论(0) 推荐(0) 编辑
摘要:题目:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.提示:此题可以使用暴力搜索方法。当然也可以使用... 阅读全文
posted @ 2015-08-28 10:32 __Neo 阅读(193) 评论(0) 推荐(0) 编辑
摘要:题目:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as... 阅读全文
posted @ 2015-08-27 21:29 __Neo 阅读(199) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't ... 阅读全文
posted @ 2015-08-26 19:46 __Neo 阅读(124) 评论(0) 推荐(0) 编辑
摘要:题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo... 阅读全文
posted @ 2015-08-26 16:20 __Neo 阅读(93) 评论(0) 推荐(0) 编辑
摘要:题目: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 two lists.提示:此题其... 阅读全文
posted @ 2015-08-26 15:42 __Neo 阅读(133) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the corre... 阅读全文
posted @ 2015-08-25 15:43 __Neo 阅读(112) 评论(0) 推荐(0) 编辑
摘要:题目:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is... 阅读全文
posted @ 2015-08-25 14:57 __Neo 阅读(156) 评论(0) 推荐(0) 编辑
摘要:题目:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After... 阅读全文
posted @ 2015-08-24 21:09 __Neo 阅读(126) 评论(0) 推荐(0) 编辑
摘要:题目:Write a function to find the longest common prefix string amongst an array of strings.代码:class Solution {public: string longestCommonPrefix(vect... 阅读全文
posted @ 2015-08-24 19:23 __Neo 阅读(120) 评论(0) 推荐(0) 编辑
摘要:题目:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.提示:此题只要熟悉罗马数字的书写语法,做起来就不会太难,关于罗马数字的介绍可以参考... 阅读全文
posted @ 2015-08-24 16:43 __Neo 阅读(136) 评论(0) 推荐(0) 编辑
摘要:题目:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font... 阅读全文
posted @ 2015-08-24 16:04 __Neo 阅读(130) 评论(0) 推荐(0) 编辑
摘要:题目:Determine whether an integer is a palindrome. Do this without extra space.提示:此题需要注意负数不是回文数。另外,我一开始的思路是把输入数字通过整除和取模运算把它倒转过来与原数字进行比较(不用考虑倒转过来的数字会不会溢出... 阅读全文
posted @ 2015-08-24 13:48 __Neo 阅读(174) 评论(0) 推荐(0) 编辑
摘要:题目:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below a... 阅读全文
posted @ 2015-08-24 11:06 __Neo 阅读(160) 评论(0) 推荐(0) 编辑
摘要:题目:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321Have you thought about this?Here are some good questions to ... 阅读全文
posted @ 2015-08-24 10:13 __Neo 阅读(153) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the ... 阅读全文
posted @ 2015-08-23 19:51 __Neo 阅读(154) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["... 阅读全文
posted @ 2015-08-23 19:20 __Neo 阅读(123) 评论(0) 推荐(0) 编辑
摘要:题目:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For ex... 阅读全文
posted @ 2015-08-22 20:42 __Neo 阅读(149) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: P... 阅读全文
posted @ 2015-08-22 19:28 __Neo 阅读(106) 评论(0) 推荐(0) 编辑
摘要:题目:Description:Count the number of prime numbers less than a non-negative number,n.提示:求素数个数的比较快速的方法是“埃拉托斯特尼筛法”,其原理很简单,具体的解释可以点击该链接。代码:一个简单的“埃拉托斯特尼筛法”实... 阅读全文
posted @ 2015-08-22 18:40 __Neo 阅读(142) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of strings, group anagrams together.For example, given:["eat", "tea", "tan", "ate", "nat", "bat"],Return:[ ["ate", "eat","tea"], [... 阅读全文
posted @ 2015-08-22 16:35 __Neo 阅读(273) 评论(0) 推荐(0) 编辑
摘要:题目:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of... 阅读全文
posted @ 2015-08-22 12:09 __Neo 阅读(358) 评论(0) 推荐(0) 编辑
摘要:题目:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep co... 阅读全文
posted @ 2015-08-21 20:34 __Neo 阅读(2496) 评论(0) 推荐(0) 编辑
摘要:题目:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled wi... 阅读全文
posted @ 2015-08-21 16:34 __Neo 阅读(143) 评论(0) 推荐(0) 编辑
摘要:题目: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 inte... 阅读全文
posted @ 2015-08-20 21:33 __Neo 阅读(210) 评论(0) 推荐(0) 编辑
摘要:题目:Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", re... 阅读全文
posted @ 2015-08-20 19:12 __Neo 阅读(113) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the diff... 阅读全文
posted @ 2015-08-20 16:00 __Neo 阅读(138) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the ... 阅读全文
posted @ 2015-08-20 11:06 __Neo 阅读(133) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].N... 阅读全文
posted @ 2015-08-20 10:27 __Neo 阅读(167) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next poi... 阅读全文
posted @ 2015-08-19 18:55 __Neo 阅读(164) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].... 阅读全文
posted @ 2015-08-19 16:17 __Neo 阅读(109) 评论(0) 推荐(0) 编辑
摘要:题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?提示:首先,题目中要求'without using extra space',... 阅读全文
posted @ 2015-08-19 15:15 __Neo 阅读(111) 评论(0) 推荐(0) 编辑
摘要:题目:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26... 阅读全文
posted @ 2015-08-19 11:00 __Neo 阅读(124) 评论(0) 推荐(0) 编辑
摘要:题目:Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: ... 阅读全文
posted @ 2015-08-19 10:00 __Neo 阅读(145) 评论(0) 推荐(0) 编辑
摘要:题目:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired byt... 阅读全文
posted @ 2015-08-18 16:35 __Neo 阅读(102) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedi... 阅读全文
posted @ 2015-08-18 16:06 __Neo 阅读(220) 评论(0) 推荐(0) 编辑
摘要:题目:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit... 阅读全文
posted @ 2015-08-18 11:32 __Neo 阅读(111) 评论(0) 推荐(0) 编辑
摘要:题目:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complet... 阅读全文
posted @ 2015-08-18 11:10 __Neo 阅读(291) 评论(0) 推荐(0) 编辑
摘要:题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical... 阅读全文
posted @ 2015-08-18 10:39 __Neo 阅读(108) 评论(0) 推荐(0) 编辑
摘要:题目:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 ... 阅读全文
posted @ 2015-08-17 17:11 __Neo 阅读(127) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complex... 阅读全文
posted @ 2015-08-17 14:22 __Neo 阅读(106) 评论(0) 推荐(0) 编辑
摘要:题目: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... 阅读全文
posted @ 2015-08-17 13:40 __Neo 阅读(123) 评论(0) 推荐(0) 编辑
摘要:题目:Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3... 阅读全文
posted @ 2015-08-17 11:37 __Neo 阅读(242) 评论(0) 推荐(0) 编辑
摘要:题目要求:Download the text filehere.The goal of this problem is to implement the "Median Maintenance" algorithm (covered in the Week 5 lecture on heap app... 阅读全文
posted @ 2015-08-16 12:34 __Neo 阅读(536) 评论(0) 推荐(0) 编辑
摘要:题目要求:Download the text filehere. (Right click and save link as).The goal of this problem is to implement a variant of the 2-SUM algorithm (covered in ... 阅读全文
posted @ 2015-08-14 10:40 __Neo 阅读(862) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示