上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 67 下一页

2018年4月14日

337 House Robber III 打家劫舍 III

摘要: 小偷又发现一个新的可行窃的地点。 这个地区只有一个入口,称为“根”。 除了根部之外,每栋房子有且只有一个父房子。 一番侦察之后,聪明的小偷意识到“这个地方的所有房屋形成了一棵二叉树”。 如果两个直接相连的房子在同一天晚上被打劫,房屋将自动报警。在不触动警报的情况下,计算小偷一晚能盗取的最高金额。示例 阅读全文

posted @ 2018-04-14 22:03 lina2014 阅读(133) 评论(0) 推荐(0) 编辑

336 Palindrome Pairs 回文对

摘要: 给定一组独特的单词, 找出在给定列表中不同 的索引对(i, j),使得关联的两个单词,例如:words[i] + words[j]形成回文。示例 1:给定 words = ["bat", "tab", "cat"]返回 [[0, 1], [1, 0]]回文是 ["battab", "tabbat"] 阅读全文

posted @ 2018-04-14 21:32 lina2014 阅读(111) 评论(0) 推荐(0) 编辑

334 Increasing Triplet Subsequence 递增的三元子序列

摘要: 给定一个未排序的数组,请判断这个数组中是否存在长度为3的递增的子序列。正式的数学表达如下: 如果存在这样的 i, j, k, 且满足 0 ≤ i < j < k ≤ n-1, 使得 arr[i] < arr[j] < arr[k] ,返回 true ; 否则返回 false 。要求算法时间复杂度为O 阅读全文

posted @ 2018-04-14 20:01 lina2014 阅读(131) 评论(0) 推荐(0) 编辑

332 Reconstruct Itinerary 重建行程单

摘要: Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tick 阅读全文

posted @ 2018-04-14 19:37 lina2014 阅读(119) 评论(0) 推荐(0) 编辑

331 Verify Preorder Serialization of a Binary Tree 验证二叉树的前序序列化

摘要: 序列化二叉树的一种方法是使用前序遍历。当我们遇到一个非空节点时,我们可以记录这个节点的值。如果它是一个空节点,我们可以使用一个标记值,例如 #。 _9_ / \ 3 2 / \ / \ 4 1 # 6/ \ / \ / \# # # # # #例如,上面的二叉树可以被序列化为字符串"9,3,4,#, 阅读全文

posted @ 2018-04-14 17:46 lina2014 阅读(169) 评论(0) 推荐(0) 编辑

330 Patching Array

摘要: Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for 阅读全文

posted @ 2018-04-14 17:37 lina2014 阅读(78) 评论(0) 推荐(0) 编辑

329 Longest Increasing Path in a Matrix 矩阵中的最长递增路径

摘要: Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or dow 阅读全文

posted @ 2018-04-14 17:22 lina2014 阅读(184) 评论(0) 推荐(0) 编辑

328 Odd Even Linked List 奇偶链表

摘要: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文

posted @ 2018-04-14 17:07 lina2014 阅读(142) 评论(0) 推荐(0) 编辑

327 Count of Range Sum 区间和计数

摘要: Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the eleme 阅读全文

posted @ 2018-04-14 16:54 lina2014 阅读(153) 评论(0) 推荐(0) 编辑

326 Power of Three 3的幂

摘要: 给出一个整数,写一个函数来确定这个数是不是3的一个幂。后续挑战:你能不使用循环或者递归完成本题吗? 详见:https://leetcode.com/problems/power-of-three/description/ C++: 方法一: 方法二: 参考:https://www.cnblogs.c 阅读全文

posted @ 2018-04-14 16:36 lina2014 阅读(120) 评论(0) 推荐(0) 编辑

上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 67 下一页

导航