leetcode327.Count of Range Sum
题目要求
1 | Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. |
这道题目是指,现有一个整数数组,并输入上界值upper和下界值lower,问数组中一共有多少组连续的子数组,其子数组中数字的和在上界和下界之内。
1 | Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. |
这道题目是指,现有一个整数数组,并输入上界值upper和下界值lower,问数组中一共有多少组连续的子数组,其子数组中数字的和在上界和下界之内。
1 | 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. |
假设有一只青蛙需要过河,河中会有一些石子,青蛙必须踩在石头上才算成功。石头的位置用整数数组来表示。青蛙的行走规则为:假设上一次青蛙跳了k格,则当前青蛙只能跳k-1或k或k+1格,且青蛙只能向前跳,不能向后跳。
1 | Given an array of characters, compress it in-place. |
对字符串进行简单的压缩操作,压缩的规则是,如果出现多个重复的字母,则用字母加上字母出现的字数进行表示。如果字母只出现一次,则不记录次数。
1 | Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this person who have a height greater than or equal to h. Write an algorithm to reconstruct the queue. |
假设有一组人站成一堆,每个人都记录下了自己的高度,以及在自己前面有多少个不比自己矮的人。现在请按照这个信息将这组人放在队列中正确的位置上并返回。
1 | Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules: |
假设有一个2D板,在板上用X表示战舰,已知板上任意两个战舰体之间一定会用.隔开,因此不会出现两个X相邻的情况。现在要求用O(N)的时间复杂度和O(1)的空间复杂度来完成。
1 | Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region. |
1 | Example 2: |
1 | Example 3: |
1 | Example 4: |
用一个二维数组来表示一堆矩形,二维数组中的每一行分别记录矩形左下角和右上角的坐标。试判断这些矩形拼接成的新的图形是否还是一个矩形。如果矩形存在重合,则不构成矩形,见图例4.
1 | Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. |
假设现在有一个用字符串表示的非负的整数,问从中删除掉k个数字后能够得到的最小结果是多少?
1 | Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. Your design should support the following methods: |
设计一个迷你推特,要求能够支持以下几个方法:发布推特,关注用户,取关用户,查看最近的十条关注用户发送的推特。
1 | Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. |
输入一个字符串,计算用这个字符串中的值构成一个最长回数的长度是多少。
1 | Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. |
假设有一个全为正整数的非空数组,将其中的数字分为两部分,确保两部分数字的和相等。