演员的自我修养


  • 首页

  • 关于我

  • 标签

  • 归档

  • 搜索

Leetcode 848 Shifting Letters

发表于 2018-06-10 |

We have a string S of lowercase letters, and an integer array shifts.
Call the shift of a letter, the next letter in the alphabet, (wrapping around so that ‘z’ becomes ‘a’).
For example, shift(‘a’) = ‘b’, shift(‘t’) = ‘u’, and shift(‘z’) = ‘a’.
Now for each shifts[i] = x, we want to shift the first i+1 letters of S, x times.
Return the final string after all such shifts to S are applied.

Example 1:
Input: S = “abc”, shifts = [3,5,9]
Output: “rpl”
Explanation:
We start with “abc”.
After shifting the first 1 letters of S by 3, we have “dbc”.
After shifting the first 2 letters of S by 5, we have “igc”.
After shifting the first 3 letters of S by 9, we have “rpl”, the answer.
Note:
1 <= S.length = shifts.length <= 20000
0 <= shifts[i] <= 10 ^ 9

阅读全文 »

美团2018CodeM初赛A轮

发表于 2018-06-09 |

共6道,2道AC,1道TLE,剩下放弃,呜呜呜,还差的太远了

阅读全文 »

美团2018CodeM资格赛

发表于 2018-06-08 |

共6道,3道AC,1道WA,2道放弃,还差的好远啊呜呜呜~

阅读全文 »

Leetcode 453 Minimum Moves to Equal Array Elements

发表于 2018-06-05 |

Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.

Example:
Input:
[1,2,3]
Output:
3
Explanation:
Only three moves are needed (remember each move increments two elements):
[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]

阅读全文 »

Leetcode 462 Minumum Moves to Equal Array Elements II

发表于 2018-06-05 |

Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1.
You may assume the array’s length is at most 10,000.

Example:
Input:
[1,2,3]
Output:
2
Explanation:
Only two moves are needed (remember each move increments or decrements one element):
[1,2,3] => [2,2,3] => [2,2,2]

阅读全文 »

Leetcode 461 Hamming Distance

发表于 2018-06-05 |


阅读全文 »

Leetcode 839 Similar String Groups

发表于 2018-06-05 |


阅读全文 »

Leetcode 846 Hand of Straights

发表于 2018-06-04 |

Alice has a hand of cards, given as an array of integers.
Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards.
Return true if and only if she can.

Example 1:
Input: hand = [1,2,3,6,2,3,4,7,8], W = 3
Output: true
Explanation: Alice’s hand can be rearranged as [1,2,3],[2,3,4],[6,7,8].

阅读全文 »

Leetcode 845 Longest Mountain in Array

发表于 2018-06-04 |

Let’s call any contiguous subarray B (of A) a mountain if the following properties hold:
B.length >= 3
There exists some 0 < i < B.length - 1 such that B[0] < B[1] < … B[i-1] < B[i] > B[i+1] > … > B[B.length - 1]

(Note that B could be any subarray of A, including the entire array A.)
Given an array A of integers, return the length of the longest mountain.
Return 0 if there is no mountain.

Example 1:
Input: [2,1,4,7,3,2,5]
Output: 5
Explanation: The largest mountain is [1,4,7,3,2] which has length 5.

阅读全文 »

Leetcode 844 Backspace String Compare

发表于 2018-06-04 |

Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.

Example 1:
Input: S = “ab#c”, T = “ad#c”
Output: true
Explanation: Both S and T become “ac”.

阅读全文 »
1…16171819
王琛

王琛

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

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