演员的自我修养


  • 首页

  • 关于我

  • 标签

  • 归档

  • 搜索

leetcode 935 Knight Dialer

发表于 2018-11-05 |

国际象棋中的骑士可以按下图所示进行移动:

这一次,我们将 “骑士” 放在电话拨号盘的任意数字键(如上图所示)上,接下来,骑士将会跳 N-1 步。每一步必须是从一个数字键跳到另一个数字键。
每当它落在一个键上(包括骑士的初始位置),都会拨出键所对应的数字,总共按下 N 位数字。

你能用这种方式拨出多少个不同的号码?
因为答案可能很大,所以输出答案模 10^9 + 7。

阅读全文 »

leetcode 934 Shortest Bridge

发表于 2018-11-05 |

在给定的二维二进制数组 A 中,存在两座岛。(岛是由四面相连的 1 形成的一个最大组。)
现在,我们可以将 0 变为 1,以使两座岛连接起来,变成一座岛。
返回必须翻转的 0 的最小数目。(可以保证答案至少是 1。)

阅读全文 »

leetcode 933 Number of Rencent Calls

发表于 2018-11-05 |

写一个 RecentCounter 类来计算最近的请求。
它只有一个方法:ping(int t),其中 t 代表以毫秒为单位的某个时间。
返回从 3000 毫秒前到现在的 ping 数。

任何处于 [t - 3000, t] 时间范围之内的 ping 都将会被计算在内,包括当前(指 t 时刻)的 ping。
保证每次对 ping 的调用都使用比之前更大的 t 值。

阅读全文 »

Leetcode 18 4Sum

发表于 2018-10-31 |

给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。

注意:
答案中不可以包含重复的四元组。

阅读全文 »

Leetcode 17 Letter Combinations of a Phone Number

发表于 2018-10-31 |

给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。
给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。
2: abc
3: def
4: ghi
5: jkl
6: mno
7: pqrs
8: tuv
9: wxyz

阅读全文 »

Leetcode 16 3Sum Closest

发表于 2018-10-31 |

给定一个包括n个整数的数组nums和一个目标值target。找出nums中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。

例如,给定数组 nums = [-1,2,1,-4], 和 target = 1.
与 target 最接近的三个数的和为 2. (-1 + 2 + 1 = 2).

阅读全文 »

Leetcode 932 Beautiful Array

发表于 2018-10-28 |

对于一个确定的N,一个数组A是漂亮的,当前仅当满足以下条件:

  1. 数组是1,2,…,N的一个迭代
  2. 对于任意的i,k,j(i < k < j),不存在A[k] * 2 = A[i] + A[j].

现在给定一个N,请你找出一个漂亮的数组A。

阅读全文 »

Leetcode 931 Minimum Falling Path Sum

发表于 2018-10-28 |

给定一个正方形矩阵A,求A中的最小下坠路径和!
一个下坠路径是指从第一行的任意一个位置开始,依次往下一行走,但相邻两行的列之差必须小于等于1!

阅读全文 »

Leetcode 930 Binary Subarrays With Sum

发表于 2018-10-28 |

给定一个只含0,1的数组,问数组中有多少个子串和恰好为S。

阅读全文 »

Leetcode 929 Unique Email Addresses

发表于 2018-10-28 |

Every email consists of a local name and a domain name, separated by the @ sign.
For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.
Besides lowercase letters, these emails may contain ‘.’s or ‘+’s.

If you add periods (‘.’) between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. For example, “alice.z@leetcode.com“ and “alicez@leetcode.com“ forward to the same email address. (Note that this rule does not apply for domain names.)

If you add a plus (‘+’) in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered, for example m.y+name@email.com will be forwarded to my@email.com. (Again, this rule does not apply for domain names.)

It is possible to use both of these rules at the same time.
Given a list of emails, we send one email to each address in the list. How many different addresses actually receive mails?

阅读全文 »
1…567…19
王琛

王琛

我要证明谁才是世界第一的actor

188 日志
27 标签
RSS
© 2020 王琛
本站访客数:
本站总访问量次