摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 阅读全文
posted @ 2017-03-20 19:44 Ci_pea 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex 阅读全文
posted @ 2017-03-20 19:38 Ci_pea 阅读(153) 评论(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 阅读全文
posted @ 2017-03-20 19:00 Ci_pea 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2017-03-18 20:02 Ci_pea 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 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-03-18 19:43 Ci_pea 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. 自己写的~~ for i in range(1,2): i 只能取到1 阅读全文
posted @ 2017-03-18 19:05 Ci_pea 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return explanation: Any row can be constructed using th 阅读全文
posted @ 2017-03-18 17:09 Ci_pea 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 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-03-18 16:59 Ci_pea 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 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-03-16 17:25 Ci_pea 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. mid = (len(nums)-1) // 2 也是正确的 阅读全文
posted @ 2017-03-15 19:03 Ci_pea 阅读(104) 评论(0) 推荐(0) 编辑