
爱写bug
公众号:爱写bug
icodebugs
爱写bug
展开
-
LeetCode 200:岛屿数量 Number of Islands
题目:给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量。一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的。你可以假设网格的四个边均被水包围。Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded...原创 2019-08-29 15:42:51 · 392 阅读 · 0 评论 -
Leetcode 542:01 矩阵 01 Matrix
题目:给定一个由 0 和 1 组成的矩阵,找出每个元素到最近的 0 的距离。两个相邻元素间的距离为 1 。Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1.示例 1:输入:0 ...原创 2019-09-17 23:35:20 · 306 阅读 · 0 评论 -
LeetCode 733: 图像渲染 flood-fill
题目:有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 到 65535 之间。An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).给你一个坐标 (sr, sc) 表示图...原创 2019-09-18 00:01:06 · 189 阅读 · 0 评论 -
LeetCode 841:钥匙和房间 Keys and Rooms
题目: 有 N 个房间,开始时你位于 0 号房间。每个房间有不同的号码:0,1,2,...,N-1,并且房间里可能有一些钥匙能使你进入下一个房间。 在形式上,对于每个房间 i 都有一个钥匙列表 rooms[i],每个钥匙 rooms[i][j] 由 [0,1,...,N-1] 中的一个整数表示,其中 N = rooms.length。 钥匙 rooms[i][j] = v 可以打开编号为 ...原创 2019-09-21 20:36:39 · 289 阅读 · 0 评论 -
哈希表(Hash Table)
概览: 简单来说,哈希表是一种依赖哈希函数组织数据,以达到常数级别时间复杂度,插入和搜索都非常高效的数据结构。两种哈系表:哈希集合是集合数据结构的实现之一,用于存储非重复值。哈希映射是映射 数据结构的实现之一,用于存储(key, value)键值对。大多数高级程序设计语言标准库里都内置了哈系表模板。1、哈希表的原理哈希表的关键思想是使用哈希函数将键映射到存储桶。更确切地说,...原创 2019-09-24 21:40:33 · 331 阅读 · 0 评论 -
LeetCode 706:设计哈希映射 Design HashMap
LeetCode 706:设计哈希映射 Design HashMap题目:不使用任何内建的哈希表库设计一个哈希映射具体地说,你的设计应该包含以下的功能put(key, value):向哈希映射中插入(键,值)的数值对。如果键对应的值已经存在,更新这个值。get(key):返回给定的键所对应的值,如果映射中不包含这个键,返回-1。remove(key):如果映射中存在这个键,删除这个...原创 2019-09-25 20:30:06 · 191 阅读 · 0 评论 -
LeetCode 705:设计哈希集合 Design HashSet
LeetCode 705:设计哈希集合 Design HashSet题目:不使用任何内建的哈希表库设计一个哈希集合具体地说,你的设计应该包含以下的功能add(value):向哈希集合中插入一个值。contains(value) :返回哈希集合中是否存在这个值。remove(value):将给定值从哈希集合中删除。如果哈希集合中没有这个值,什么也不做。Design a HashSe...原创 2019-09-25 20:30:25 · 381 阅读 · 0 评论 -
LeetCode 217:存在重复元素 Contains Duplicate
题目:给定一个整数数组,判断是否存在重复元素。Given an array of integers, find if the array contains any duplicates.如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。Your function should return true if any value appears...原创 2019-09-25 20:30:44 · 111 阅读 · 0 评论