演员的自我修养


  • 首页

  • 关于我

  • 标签

  • 归档

  • 搜索

Leetcode 841 Keys and Rooms

发表于 2018-05-28 |

There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have some keys to access the next room.

Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, …, N-1] where N = rooms.length. A key rooms[i][j] = v opens the room with number v.

Initially, all the rooms start locked (except for room 0).
You can walk back and forth between rooms freely.
Return true if and only if you can enter every room.

阅读全文 »

Leetcode 840 Magic Squares In Grid

发表于 2018-05-28 |

A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.

Given an grid of integers, how many 3 x 3 “magic square” subgrids are there? (Each subgrid is contiguous).

阅读全文 »

Leetcode 611 Valid Triangle Number

发表于 2018-05-28 |

Valid Triangle Number

Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.

Example 1:
Input: [2,2,3,4]
Output: 3
Explanation:
Valid combinations are:
2,3,4 (using the first 2)
2,3,4 (using the second 2)
2,2,3

阅读全文 »

Leetcode 802 Find Eventual Safe States

发表于 2018-05-22 |

description

阅读全文 »

Leetcode 838 Push Dominoes

发表于 2018-05-22 |

图1

阅读全文 »

Leetcode 836 Rectangle Overlap

发表于 2018-05-22 |

A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordinates of its top-right corner.

Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.

Given two rectangles, return whether they overlap.

阅读全文 »

Leetcode 837 New 21 Game

发表于 2018-05-22 |

Alice plays the following game, loosely based on the card game “21”.

Alice starts with 0 points, and draws numbers while she has less than K points. During each draw, she gains an integer number of points randomly from the range [1, W], where W is an integer. Each draw is independent and the outcomes have equal probabilities.

Alice stops drawing numbers when she gets K or more points. What is the probability that she has N or less points?

Example 1:
Input: N = 10, K = 1, W = 10
Output: 1.00000
Explanation: Alice gets a single card, then stops.

阅读全文 »

Leetcode 459 Repeated Substring Pattern

发表于 2018-05-19 |

Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.

Example 1:
Input: “abab”
Output: True
Explanation: It’s the substring “ab” twice.>

阅读全文 »

Leetcode 821 Shortest Distance to a Character

发表于 2018-05-11 |

Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.

Example 1:
Input: S = “loveleetcode”, C = ‘e’
Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]

阅读全文 »

Leetcode 822 Card Flipping Game

发表于 2018-05-11 |

On a table are N cards, with a positive integer printed on the front and back of each card (possibly different).

We flip any number of cards, and after we choose one card.

If the number X on the back of the chosen card is not on the front of any card, then this number X is good.

What is the smallest number that is good? If no number is good, output 0.

阅读全文 »
1…171819
王琛

王琛

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

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