上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 29 下一页
摘要: 题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears 阅读全文
posted @ 2020-01-12 00:48 silentteller 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the 阅读全文
posted @ 2020-01-08 16:35 silentteller 阅读(445) 评论(0) 推荐(0) 编辑
摘要: 题目: Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the 阅读全文
posted @ 2020-01-06 15:10 silentteller 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get 阅读全文
posted @ 2020-01-06 00:24 silentteller 阅读(712) 评论(0) 推荐(0) 编辑
摘要: 题目: 给你一根长度为n的绳子,请把绳子剪成整数长的m段(m、n都是整数,n>1并且m>1),每段绳子的长度记为k[0],k[1],...,k[m]。请问k[0]xk[1]x...xk[m]可能的最大乘积是多少?例如,当绳子的长度是8时,我们把它剪成长度分别为2、3、3的三段,此时得到的最大乘积是1 阅读全文
posted @ 2019-12-31 15:54 silentteller 阅读(397) 评论(0) 推荐(0) 编辑
摘要: 题目: 地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为3+5 阅读全文
posted @ 2019-12-31 15:34 silentteller 阅读(459) 评论(0) 推荐(0) 编辑
摘要: 题目: 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。 例如 a b c e s f c s a d e e 矩阵中 阅读全文
posted @ 2019-12-31 14:52 silentteller 阅读(337) 评论(0) 推荐(1) 编辑
摘要: 题目: 给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4], 阅读全文
posted @ 2019-12-30 14:33 silentteller 阅读(419) 评论(0) 推荐(0) 编辑
摘要: 题目: 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。我们使用Insert()方法读取数据流,使用GetMedian()方法获取当前读取数据的中位数。 分析: 阅读全文
posted @ 2019-12-30 12:23 silentteller 阅读(378) 评论(0) 推荐(0) 编辑
摘要: 题目: 给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4。 分析: 二叉搜索树的中序遍历结果正好是按数值升序排列的结果,我们可以利用前序遍历将结点按val值的顺序存储到数组中,然后直接按索引返回即可。 程序: C++ cl 阅读全文
posted @ 2019-12-30 11:11 silentteller 阅读(262) 评论(2) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 29 下一页