
Hash Table
str_818
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【Leetcode】217. 存在重复元素(Contains Duplicate)
Leetcode - 217 Contains Duplicate (Easy) 题目描述:判断数组中是否存在重复元素。 Input: [1,2,3,1] Output: true public boolean containsDuplicate(int[] nums) { Set<Integer> set = new HashSet<>(); for (...原创 2019-05-30 10:24:11 · 146 阅读 · 0 评论 -
【Leetcode】36. 有效的数独(Valid Sudoku)
Leetcode - 36 Valid Sudoku (Medium) 题目描述:给定一个 9 × 9 的不完整数独数组,判定是否合法。 解题思路:判断每一行、每一列和每个 3 × 3 单元格是否有重复的数字。 public boolean isValidSudoku(char[][] board) { boolean[][] row = new boolean[9][9]; bo...原创 2019-06-06 10:19:40 · 221 阅读 · 0 评论 -
【Leetcode】1. 两数之和(Two Sum)
Leetcode - 1 Two Sum (Easy) 题目描述:给定一个数组,返回相加和为 target 的两个元素的下标。 Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. public int[] twoSum(int[] nums, int tar...原创 2019-06-02 10:52:19 · 197 阅读 · 0 评论 -
【Leetcode】3. 无重复字符的最长子串(Longest Substring Without Repeating Characters)
Leetcode - 3 Longest Substring Without Repeating Characters (Medium) Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. 解题思路:使用 HashMap 记录出现字符的位置,利用双指针滑动窗口记录子串的长度。 ...原创 2019-06-02 11:28:31 · 172 阅读 · 0 评论