随笔分类 - Leetcode
摘要:On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east. Here, the north-west corner of the grid is at the first row and c
阅读全文
摘要:Given the radius and x-y positions of the center of a circle, write a function randPoint which generates a uniform random point in the circle. Note: E
阅读全文
摘要:Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero. Return
阅读全文
摘要:Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's only divisors are 1 and itself, and it is greater
阅读全文
摘要:There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining c
阅读全文
摘要:Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers? Example 1: Example 2: Example 3: Note: 1 <= N <=
阅读全文
摘要: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
阅读全文
摘要:You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points. Notes: 3 <= points.length <
阅读全文
摘要:In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.) Return true if and only if af
阅读全文
摘要:A Tic-Tac-Toe board is given as a string array board. Return True if and only if it is possible to reach this board position during the course of a va
阅读全文
摘要:You are playing a simplified Pacman game. You start at the point (0, 0), and your destination is (target[0], target[1]). There are several ghosts on t
阅读全文
摘要:There is a box protected by a password. The password is n digits, where each letter can be one of the first k digits 0, 1, ..., k-1. You can keep inpu
阅读全文
摘要:A move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y). Given a starting point (sx, sy) and a target point (tx, t
阅读全文
摘要:You are standing at position 0 on an infinite number line. There is a goal at position target. On each move, you can either go left or right. During t
阅读全文
摘要:The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another n
阅读全文
摘要:Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Example 2: Approach #1:
阅读全文
摘要:Given a string representing an expression of fraction addition and subtraction, you need to return the calculation result in string format. The final
阅读全文
摘要:Given the coordinates of four points in 2D space, return whether the four points could construct a square. The coordinate (x,y) of a point is represen
阅读全文
摘要:There are 1000 buckets, one and only one of them is poisonous, while the rest are filled with water. They all look identical. If a pig drinks the pois
阅读全文
摘要: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
阅读全文