哈希表
LUCASYAN个
这个作者很懒,什么都没留下…
展开
-
659. Split Array into Consecutive Subsequences 堆、优先级队列、哈希表
You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subsequences consist of at least 3 consecutive integers.原创 2017-09-14 13:45:50 · 233 阅读 · 0 评论 -
36. Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partially fille原创 2017-09-14 19:13:21 · 152 阅读 · 0 评论 -
525. Contiguous Array
给定一个数组,只包含0和1,求最大的子数组长度,使得0和1的数目相等。 思路: 这个问题可以转变成560 最长区间和为给定值这道题。只需要将0改成-1.建立一个哈希标保存,累加和是一个值的最左位置。当前位置i的累加和是x,那么只要找到最左边累加和也是x的位置j,那么(j,i]的累加和就是0,说明0和1的数目相等。 这个题注意两点: 1、加和为0的位置设置成-1; 2、由于map的默认值是原创 2017-09-12 14:41:00 · 154 阅读 · 0 评论 -
594. Longest Harmonious Subsequence
We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1. Now, given an integer array, you need to find the length of its longest h原创 2017-09-12 16:54:11 · 164 阅读 · 0 评论 -
403. Frog Jump
A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of s原创 2017-09-22 15:11:40 · 275 阅读 · 0 评论