随笔分类 -  LeetCode

摘要:Spiral Matrix II (M) 题目 Given a positive integer n, generate a square matrix filled with elements from 1 to \(n^2\) in spiral order. Example: Input: 3 阅读全文
posted @ 2020-07-06 02:49 墨云黑 阅读(142) 评论(0) 推荐(0)
摘要:Length of Last Word (E) 题目 Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in t 阅读全文
posted @ 2020-07-06 02:03 墨云黑 阅读(164) 评论(0) 推荐(0)
摘要:Hamming Distance (E) 题目 The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two 阅读全文
posted @ 2020-07-06 01:53 墨云黑 阅读(174) 评论(0) 推荐(0)
摘要:Valid Perfect Square (E) 题目 Given a positive integer num, write a function which returns True if num is a perfect square else False. Follow up: Do not 阅读全文
posted @ 2020-07-05 03:56 墨云黑 阅读(131) 评论(0) 推荐(0)
摘要:Insert Interval (H) 题目 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that th 阅读全文
posted @ 2020-07-05 03:33 墨云黑 阅读(181) 评论(0) 推荐(0)
摘要:Ugly Number II (M) 题目 Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Exampl 阅读全文
posted @ 2020-07-05 02:09 墨云黑 阅读(220) 评论(0) 推荐(0)
摘要:Merge Intervals (M) 题目 Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6] 阅读全文
posted @ 2020-07-04 02:57 墨云黑 阅读(169) 评论(0) 推荐(0)
摘要:Jump Game (M) 题目 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array repr 阅读全文
posted @ 2020-07-04 02:38 墨云黑 阅读(179) 评论(0) 推荐(0)
摘要:Prison Cells After N Days (M) 题目 There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied 阅读全文
posted @ 2020-07-04 01:59 墨云黑 阅读(253) 评论(0) 推荐(0)
摘要:Spiral Matrix (M) 题目 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Input: [ [ 1, 阅读全文
posted @ 2020-07-03 03:19 墨云黑 阅读(160) 评论(0) 推荐(0)
摘要:Maximum Subarray (E) 题目 Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and retur 阅读全文
posted @ 2020-07-03 01:12 墨云黑 阅读(168) 评论(0) 推荐(0)
摘要:Binary Tree Level Order Traversal II (E) 题目 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to ri 阅读全文
posted @ 2020-07-03 00:52 墨云黑 阅读(153) 评论(0) 推荐(0)
摘要:N-Queens II (H) 题目 The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an int 阅读全文
posted @ 2020-07-02 08:45 墨云黑 阅读(236) 评论(0) 推荐(0)
摘要:N-Queens (H) 题目 The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an intege 阅读全文
posted @ 2020-07-02 04:54 墨云黑 阅读(205) 评论(0) 推荐(0)
摘要:Arranging Coins (E) 题目 You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n 阅读全文
posted @ 2020-07-02 03:52 墨云黑 阅读(195) 评论(0) 推荐(0)
摘要:Odd Even Linked List (M) 题目 Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about 阅读全文
posted @ 2020-07-01 07:04 墨云黑 阅读(161) 评论(0) 推荐(0)
摘要:Counting Bits (M) 题目 Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary 阅读全文
posted @ 2020-07-01 06:46 墨云黑 阅读(192) 评论(0) 推荐(0)
摘要:Top K Frequent Elements (M) 题目 Given a non-empty array of integers, return the *k* most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 阅读全文
posted @ 2020-07-01 06:01 墨云黑 阅读(148) 评论(0) 推荐(0)
摘要:Pow(x, n) (M) 题目 mplement pow(x, n), which calculates x raised to the power n (\(x^n\)). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: I 阅读全文
posted @ 2020-07-01 03:08 墨云黑 阅读(215) 评论(0) 推荐(0)
摘要:Group Anagrams (M) 题目 Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate" 阅读全文
posted @ 2020-07-01 02:25 墨云黑 阅读(147) 评论(0) 推荐(0)