Redtongue

人生苦短,我用Python


  • 首页

  • 归档

  • 分类

  • 标签

  • 关于

  • 搜索

947.Most Stonees Removed with Same Row or Column(移除最多的同行或同列石头)

发表于 2018-11-25 | 更新于: 2018-12-11 | 分类于 leetcode

Description

On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone.

Now, a move consists of removing a stone that shares a column or row with another stone on the grid.

What is the largest possible number of moves we can make?


在二维平面上,我们将石头放置在一些整数坐标点上。每个坐标点上最多只能有一块石头。

现在,move 操作将会移除与网格上的另一块石头共享一列或一行的石头。

我们最多能执行多少次 move 操作?

题目链接:https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/

Difficulty: hard

阅读全文 »

946.Validate Stack Sequence(验证栈序列)

发表于 2018-11-25 | 更新于: 2018-12-11 | 分类于 leetcode

Description

Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack.


给定 pushed 和 popped 两个序列,只有当它们可能是在最初空栈上进行的推入 push 和弹出 pop 操作序列的结果时,返回 true;否则,返回 false 。

题目链接:https://leetcode.com/problems/validate-stack-sequences/

Difficulty: medium

阅读全文 »

945.Minimum Increment to Make Array Unique(使数组唯一的最小增量)

发表于 2018-11-25 | 更新于: 2018-12-11 | 分类于 leetcode

Description

Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1.

Return the least number of moves to make every value in A unique.


给定整数数组 A,每次 move 操作将会选择任意 A[i],并将其递增 1。

返回使 A 中的每个值都是唯一的最少操作次数。

题目链接:https://leetcode.com/problems/minimum-increment-to-make-array-unique/

Difficulty: medium

阅读全文 »

944.Delete Columns to Make Sorted(删除列以使之有序)

发表于 2018-11-18 | 更新于: 2018-11-18 | 分类于 leetcode

Description

We are given an array A of N lowercase letter strings, all of the same length.

Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.

For example, if we have a string “abcdef” and deletion indices {0, 2, 3}, then the final string after deletion is “bef”.

Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.

Formally, the c-th column is [A[0][c], A[1][c], …, A[A.length-1][c]]

Return the minimum possible value of D.length.


给出由 N 个小写字母串组成的数组 A,所有小写字母串的长度都相同。

现在,我们可以选择任何一组删除索引,对于每个字符串,我们将删除这些索引中的所有字符。

举个例子,如果字符串为 “abcdef”,且删除索引是 {0, 2, 3},那么删除之后的最终字符串为 “bef”。

假设我们选择了一组删除索引 D,在执行删除操作之后,A 中剩余的每一列都是有序的。

形式上,第 c 列为 [A[0][c], A[1][c], …, A[A.length-1][c]]

返回 D.length 的最小可能值。

题目链接:https://leetcode.com/problems/delete-columns-to-make-sorted/

Difficulty: medium

阅读全文 »

943.Find the Shortest Superstring(最短超级串)

发表于 2018-11-18 | 更新于: 2018-11-18 | 分类于 leetcode

Description

Given an array A of strings, find any smallest string that contains each string in A as a substring.

We may assume that no string in A is substring of another string in A.


给定一个字符串数组 A,找到以 A 中每个字符串作为子字符串的最短字符串。

我们可以假设 A 中没有字符串是 A 中另一个字符串的子字符串。

题目链接:https://leetcode.com/problems/find-the-shortest-superstring/

Difficulty: hard

阅读全文 »

942.DI String Match(增减字符串匹配)

发表于 2018-11-18 | 更新于: 2018-11-18 | 分类于 leetcode

Description

Given a string S that only contains “I” (increase) or “D” (decrease), let N = S.length.

Return any permutation A of [0, 1, …, N] such that for all i = 0, …, N-1:

  • If S[i] == “I”, then A[i] < A[i+1]
  • If S[i] == “D”, then A[i] > A[i+1]

给定只含 “I”(增大)或 “D”(减小)的字符串 S ,令 N = S.length。

返回 [0, 1, …, N] 的任意排列 A 使得对于所有 i = 0, …, N-1,都有:

  • 如果 S[i] == “I”,那么 A[i] < A[i+1]
  • 如果 S[i] == “D”,那么 A[i] > A[i+1]

题目链接:https://leetcode.com/problems/di-string-match/

Difficulty: easy

阅读全文 »

941.Valid Mountain Array(有效的山脉数组)

发表于 2018-11-18 | 更新于: 2018-11-18 | 分类于 leetcode

Description

Given an array A of integers, return true if and only if it is a valid mountain array.

Recall that A is a mountain array if and only if:

  • A.length >= 3
  • There exists some i with 0 < i < A.length - 1 such that:
    • A[0] < A[1] < … A[i-1] < A[i]
    • A[i] > A[i+1] > … > A[B.length - 1]

给定一个整数数组 A,如果它是有效的山脉数组就返回 true,否则返回 false。

让我们回顾一下,如果 A 满足下述条件,那么它是一个山脉数组:

  • A.length >= 3
  • 在 0 < i < A.length - 1 条件下,存在 i 使得:
    • A[0] < A[1] < … A[i-1] < A[i]
    • A[i] > A[i+1] > … > A[B.length - 1]

题目链接:https://leetcode.com/problems/valid-mountain-array/

Difficulty: easy

阅读全文 »

Git 和 Github

发表于 2018-11-14 | 更新于: 2018-11-18 | 分类于 whatever

以下教程没用具体的代码截图,言简意赅,都是具体的操作,就是为了自己以后当作笔记来看,可以参考廖雪峰

Git 教程

安装Git

在Windows上安装Git,可以从Git官网直接下载安装程序,(网速慢的朋友这里),然后按默认选项安装即可。

安装完成后,在开始菜单中打开Git Bash,输入如下命令:

阅读全文 »

940.Distinct Subsequences II(不同的子序列 II)

发表于 2018-11-11 | 更新于: 2018-11-11 | 分类于 leetcode

Description

Given a string S, count the number of distinct, non-empty subsequences of S .

Since the result may be large, return the answer modulo 10^9 + 7.


给定一个字符串 S,计算 S 的不同非空子序列的个数。

因为结果可能很大,所以返回答案模 10^9 + 7.

题目链接:https://leetcode.com/problems/distinct-subsequences-ii/

Difficulty: hard

阅读全文 »

939.Minimum Area Rectangle(最小面积矩形)

发表于 2018-11-11 | 更新于: 2018-11-11 | 分类于 leetcode

Description

Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes.

If there isn’t any rectangle, return 0.


给定在 xy 平面上的一组点,确定由这些点组成的矩形的最小面积,其中矩形的边平行于 x 轴和 y 轴。

如果没有任何矩形,就返回 0。

题目链接:https://leetcode.com/problems/minimum-area-rectangle/

Difficulty: medium

阅读全文 »
1…678…21
yunxiang wang

yunxiang wang

记录点点

202 日志
4 分类
41 标签
GitHub E-Mail
© 2016 — 2020 yunxiang wang