随笔分类 -  Leetcode (Java)

上一页 1 2 3 4 5 下一页

218. 天际线问题 (JAVA)
摘要:城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。现在,假设您获得了城市风光照片(图A)上显示的所有建筑物的位置和高度,请编写一个程序以输出由这些建筑物形成的天际线(图B)。 每个建筑物的几何信息用三元组 [Li,Ri,Hi] 表示,其中 Li 和 Ri 分别是第 i 座建筑物左右边缘 阅读全文

posted @ 2020-08-05 12:05 joannae 阅读(290) 评论(0) 推荐(0)

347. 前 K 个高频元素 (JAVA)
摘要:给定一个非空的整数数组,返回其中出现频率前 k 高的元素。 示例 1: 输入: nums = [1,1,1,2,2,3], k = 2输出: [1,2]示例 2: 输入: nums = [1], k = 1输出: [1] 提示: 你可以假设给定的 k 总是合理的,且 1 ≤ k ≤ 数组中不相同的元 阅读全文

posted @ 2020-08-03 23:07 joannae 阅读(275) 评论(0) 推荐(0)

212. 单词搜索 II (JAVA)
摘要:给定一个二维网格 board 和一个字典中的单词列表 words,找出所有同时在二维网格和字典中出现的单词。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母在一个单词中不允许被重复使用。 示例: 输入: words = [ 阅读全文

posted @ 2020-08-02 21:17 joannae 阅读(303) 评论(0) 推荐(0)

210. 课程表 II (JAVA)
摘要:现在你总共有 n 门课需要选,记为 0 到 n-1。 在选修某些课程之前需要一些先修课程。 例如,想要学习课程 0 ,你需要先完成课程 1 ,我们用一个匹配来表示他们: [0,1] 给定课程总量以及它们的先决条件,返回你为了学完所有课程所安排的学习顺序。 可能会有多个正确的顺序,你只要返回一种就可以 阅读全文

posted @ 2020-08-02 11:42 joannae 阅读(373) 评论(0) 推荐(0)

208. 实现 Trie (前缀树) (JAVA)
摘要:实现一个 Trie (前缀树),包含 insert, search, 和 startsWith 这三个操作。 示例: Trie trie = new Trie(); trie.insert("apple");trie.search("apple"); // 返回 truetrie.search("a 阅读全文

posted @ 2020-08-01 07:53 joannae 阅读(189) 评论(0) 推荐(0)

面试题 08.11. 硬币 (Java)
摘要:硬币。给定数量不限的硬币,币值为25分、10分、5分和1分,编写代码计算n分有几种表示法。(结果可能会很大,你需要将结果模上1000000007) 示例1: 输入: n = 5 输出:2 解释: 有两种方式可以凑成总金额:5=55=1+1+1+1+1示例2: 输入: n = 10 输出:4 解释: 阅读全文

posted @ 2020-07-15 10:53 joannae 阅读(283) 评论(0) 推荐(0)

350. 两个数组的交集 II (Java)
摘要:给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入:nums1 = [1,2,2,1], nums2 = [2,2]输出:[2,2]示例 2: 输入:nums1 = [4,9,5], nums2 = [9,4,9,8,4]输出:[4,9] 说明: 输出结果中每个元素出现的次数,应与元素在 阅读全文

posted @ 2020-07-13 23:14 joannae 阅读(232) 评论(0) 推荐(0)

面试题 17.13. 恢复空格 (JAVA)
摘要:哦,不!你不小心把一个长篇文章中的空格、标点都删掉了,并且大写也弄成了小写。像句子"I reset the computer. It still didn’t boot!"已经变成了"iresetthecomputeritstilldidntboot"。在处理标点符号和大小写之前,你得先把它断成词语 阅读全文

posted @ 2020-07-11 00:55 joannae 阅读(196) 评论(0) 推荐(0)

76. 最小覆盖子串 (JAVA)
摘要:给你一个字符串 S、一个字符串 T,请在字符串 S 里面找出:包含 T 所有字符的最小子串。 示例: 输入: S = "ADOBECODEBANC", T = "ABC"输出: "BANC"说明: 如果 S 中不存这样的子串,则返回空字符串 ""。如果 S 中存在这样的子串,我们保证它是唯一的答案。 阅读全文

posted @ 2020-07-05 20:35 joannae 阅读(774) 评论(0) 推荐(0)

95. 不同的二叉搜索树 II (Java)
摘要:给定一个整数 n,生成所有由 1 ... n 为节点所组成的 二叉搜索树 。 示例: 输入:3输出:[ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], [1,null,2,null,3]]解释:以上的输出对应以下 5 种不同结构的二叉搜 阅读全文

posted @ 2020-07-04 14:27 joannae 阅读(248) 评论(0) 推荐(0)

94. Binary Tree Inorder Traversal (Java)
摘要:Given a binary tree, return the inorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iteratively 阅读全文

posted @ 2019-07-22 11:26 joannae 阅读(139) 评论(0) 推荐(0)

90. Subsets II (Java)
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文

posted @ 2019-07-19 15:29 joannae 阅读(126) 评论(0) 推荐(0)

89. Gray Code (Java)
摘要:The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total num 阅读全文

posted @ 2019-07-19 14:14 joannae 阅读(236) 评论(0) 推荐(0)

87. Scramble String (Java)
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati 阅读全文

posted @ 2019-07-04 19:37 joannae 阅读(174) 评论(0) 推荐(0)

51. N-Queens (JAVA)
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文

posted @ 2019-06-28 21:04 joannae 阅读(255) 评论(0) 推荐(0)

85. Maximal Rectangle (JAVA)
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文

posted @ 2019-05-30 15:35 joannae 阅读(200) 评论(0) 推荐(0)

84. Largest Rectangle in Histogram (JAVA)
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文

posted @ 2019-05-28 17:33 joannae 阅读(149) 评论(0) 推荐(0)

81. Search in Rotated Sorted Array II (JAVA)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). Y 阅读全文

posted @ 2019-05-28 11:19 joannae 阅读(123) 评论(0) 推荐(0)

77. Combinations (JAVA)
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: 带回溯的递归。(带回溯没法 阅读全文

posted @ 2019-05-27 10:55 joannae 阅读(136) 评论(0) 推荐(0)

76. Minimum Window Substring (JAVA)
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Note: If there i 阅读全文

posted @ 2019-05-24 18:33 joannae 阅读(280) 评论(0) 推荐(0)

上一页 1 2 3 4 5 下一页

导航