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

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)
 
 

公告


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