• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
UsSam
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理
上一页 1 2 3 4 下一页

2014年3月22日

【Leetcode】Valid Number
摘要: 题目:Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implemen 阅读全文
posted @ 2014-03-22 19:12 UsSam 阅读(130) 评论(0) 推荐(0)
 
 

2014年3月20日

【Leetcode】Valid Palindrome
摘要: 题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isnota palindrome.Note:Have you consider that the string might be empty? This is a good question 阅读全文
posted @ 2014-03-20 18:51 UsSam 阅读(113) 评论(0) 推荐(0)
 
【Leetcode】Swap Nodes in Pairs
摘要: 题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values in the list, only nodes itself can be changed.解题思路:本题较简单,做3次指针变换 阅读全文
posted @ 2014-03-20 18:04 UsSam 阅读(104) 评论(0) 推荐(0)
 
【Leetcode】Remove Nth Node From End of List
摘要: 题目: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 removing the second node from the end, the linked list becomes 1->2->3->5.Note:Givennwill always be valid.Try to do this in one pass 阅读全文
posted @ 2014-03-20 16:19 UsSam 阅读(135) 评论(0) 推荐(0)
 
【Leetcode】Climbing Stairs
摘要: 题目: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 climb to the top?解题思路:这是一道斐波拉契数列题。看到斐波那契数列就自然想到利用递归,然而在这里递归的效率非常低,荣誉计算的数量增长的非常快,直接导致出现TLE(Time Limit Exceeded)错误。这是因为在递归的时候许多值被重复计算了多次,根据《C和指针》上对斐波那契数列的 阅读全文
posted @ 2014-03-20 15:07 UsSam 阅读(134) 评论(0) 推荐(0)
 
【Leetcode】Valid Sudoku
摘要: 题目:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character'.'.A partially filled sudoku which is valid.Note:A valid Sudoku board (partially filled) is not necessarily solvable. Only th 阅读全文
posted @ 2014-03-20 11:24 UsSam 阅读(114) 评论(0) 推荐(0)
 
 

2014年3月17日

【Leetcode】Word Ladder II
摘要: 题目:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example,Given:start="hit"end="cog"dict=["hot"," 阅读全文
posted @ 2014-03-17 21:48 UsSam 阅读(145) 评论(0) 推荐(0)
 
 

2014年3月16日

【Leetcode】Word Ladder
摘要: 题目:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example,Given:start="hit"end="cog"dict=["hot" 阅读全文
posted @ 2014-03-16 16:10 UsSam 阅读(135) 评论(0) 推荐(0)
 
 

2014年3月15日

【Leetcode】Path Sum
摘要: 题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / ... 阅读全文
posted @ 2014-03-15 19:34 UsSam 阅读(99) 评论(0) 推荐(0)
 
【Leetcode】Maximum Depth of Binary Tree
摘要: 题目: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 leaf node.解题思路:当节点为空时,返回0,否则返回左右儿子中最深的深度值。代码:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode... 阅读全文
posted @ 2014-03-15 18:36 UsSam 阅读(122) 评论(0) 推荐(0)
 
 
上一页 1 2 3 4 下一页

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3