随笔分类 -  Leetcode

上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: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 @ 2014-11-16 12:41 Jessica程序猿 阅读(175) 评论(0) 推荐(0)
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2014-11-16 09:43 Jessica程序猿 阅读(223) 评论(0) 推荐(0)
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2014-11-15 22:33 Jessica程序猿 阅读(191) 评论(0) 推荐(0)
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文
posted @ 2014-11-15 20:53 Jessica程序猿 阅读(153) 评论(0) 推荐(0)
摘要:Sort a linked list using insertion sort.C++代码如下:#include#includeusing namespace std;//Definition for singly-linked list.struct ListNode{ int val; ... 阅读全文
posted @ 2014-11-15 20:08 Jessica程序猿 阅读(216) 评论(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 an... 阅读全文
posted @ 2014-11-15 17:22 Jessica程序猿 阅读(170) 评论(0) 推荐(0)
摘要:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2014-11-15 17:03 Jessica程序猿 阅读(240) 评论(0) 推荐(0)
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2014-11-15 16:47 Jessica程序猿 阅读(203) 评论(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 fo... 阅读全文
posted @ 2014-11-15 15:30 Jessica程序猿 阅读(201) 评论(0) 推荐(0)
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are som... 阅读全文
posted @ 2014-11-15 12:38 Jessica程序猿 阅读(164) 评论(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 and ... 阅读全文
posted @ 2014-11-15 11:03 Jessica程序猿 阅读(218) 评论(0) 推荐(0)
摘要:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki... 阅读全文
posted @ 2014-11-15 08:55 Jessica程序猿 阅读(155) 评论(0) 推荐(0)
摘要:Write a function to find the longest common prefix string amongst an array of strings.(每个字符串从0开始的公共部分即最长公共前缀)C++代码如下:#include#include#includeusing nam... 阅读全文
posted @ 2014-11-14 22:18 Jessica程序猿 阅读(249) 评论(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 re... 阅读全文
posted @ 2014-11-14 21:46 Jessica程序猿 阅读(178) 评论(0) 推荐(0)
摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
posted @ 2014-11-14 20:27 Jessica程序猿 阅读(167) 评论(0) 推荐(0)
摘要:Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文
posted @ 2014-11-14 19:59 Jessica程序猿 阅读(138) 评论(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 mat... 阅读全文
posted @ 2014-11-14 19:04 Jessica程序猿 阅读(120) 评论(0) 推荐(0)
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.这个题应该就是求子串的问题,改进的方法是kmp算法。... 阅读全文
posted @ 2014-11-14 17:22 Jessica程序猿 阅读(229) 评论(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 doe... 阅读全文
posted @ 2014-11-14 16:04 Jessica程序猿 阅读(200) 评论(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.C++代码如下:#... 阅读全文
posted @ 2014-11-14 15:33 Jessica程序猿 阅读(210) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 下一页