2017年12月21日

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: Pan 阅读全文

posted @ 2017-12-21 20:09 夜的第八章 阅读(130) 评论(0) 推荐(0) 编辑

two sum II

摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文

posted @ 2017-12-21 19:12 夜的第八章 阅读(155) 评论(0) 推荐(0) 编辑

Best Time to Buy and Sell Stock i

摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文

posted @ 2017-12-21 16:49 夜的第八章 阅读(132) 评论(0) 推荐(0) 编辑

Pascal's Triangle II

摘要: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us 阅读全文

posted @ 2017-12-21 16:29 夜的第八章 阅读(108) 评论(0) 推荐(0) 编辑

Pascal's Triangle(杨辉三角)

摘要: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 思路:动态规划,前面的构建出来了,后面根据某种关系也就可以构建出来。 这个要根据前一行来构建下一 阅读全文

posted @ 2017-12-21 15:28 夜的第八章 阅读(209) 评论(2) 推荐(0) 编辑

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. F 阅读全文

posted @ 2017-12-21 14:27 夜的第八章 阅读(139) 评论(0) 推荐(0) 编辑

balanced binary tree(判断是否是平衡二叉树)

摘要: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文

posted @ 2017-12-21 13:55 夜的第八章 阅读(208) 评论(0) 推荐(0) 编辑

二叉堆

摘要: 二叉堆 我们知道堆栈是一种LIFO(后进先出)结构,队列是一种FIFO(先进先出)结构,而二叉堆是一种最小值先出的数据结构,因此二叉堆很适合用来做排序。 二叉堆的性质:二叉堆是一棵完全二叉树。 二叉堆采用数组来存储(按广度优先遍历的顺序),而没有像普通的树结构使用指针来表示节点间的关系。 如下图所示 阅读全文

posted @ 2017-12-21 11:01 夜的第八章 阅读(341) 评论(1) 推荐(0) 编辑

导航