LeetCode学习笔记
玲珑子_a
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode: 171 Excel Sheet Column Number(easy) C++
题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ...原创 2018-12-05 21:48:18 · 184 阅读 · 0 评论 -
LeetCode: 136 Single Number(easy)
题目: Given an array of integers, every element appearstwiceexcept for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using e...原创 2019-04-18 10:20:30 · 147 阅读 · 0 评论 -
LeetCode: 292 Nim Game(easy)
题目: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will b...原创 2019-04-18 10:20:38 · 159 阅读 · 0 评论 -
LeetCode: 521 Longest Uncommon Subsequence I(easy)
题目: anysubsequence of the other strings. Asubsequenceis a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially...原创 2019-04-18 10:20:44 · 137 阅读 · 0 评论 -
LeetCode: 637 Average of Levels in Binary Tree
题目: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 1...原创 2019-04-17 14:23:24 · 122 阅读 · 0 评论 -
LeetCode: 496 Next Greater Element I(easy)
题目: You are given two arrays(without duplicates)nums1andnums2wherenums1’s elements are subset ofnums2. Find all the next greater numbers fornums1's elements in the corresponding places ofnum...原创 2019-04-17 14:23:35 · 143 阅读 · 0 评论 -
LeetCode: 463 Island Perimeter(easy)
题目: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is comple...原创 2019-04-17 14:23:42 · 139 阅读 · 0 评论 -
LeetCode: 620 Not Boring Movies(easy)
题目: X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output mo...原创 2019-04-17 14:23:55 · 148 阅读 · 0 评论 -
LeetCode: 412 Fizz Buzz(easy)
题目: Write a program that outputs the string representation of numbers from 1 ton. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz...原创 2019-04-17 14:24:05 · 149 阅读 · 0 评论 -
LeetCode: 344 Reverse String
题目: Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". 代码: 自己的: class Solution { public: string reverseString(string...原创 2019-04-17 14:24:13 · 176 阅读 · 0 评论 -
LeetCode: 566 Reshape the Matrix
题目: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. You're given a matrix represented by a two-...原创 2019-04-17 14:24:36 · 230 阅读 · 0 评论 -
LeetCode: 575 Distribute Candies(easy)
题目: Given an integer array withevenlength, where different numbers in this array represent differentkindsof candies. Each number means one candy of the corresponding kind. You need to distribute ...原创 2019-04-17 14:24:47 · 245 阅读 · 0 评论 -
LeetCode: 557Reverse Words in a String III(easy)
题目: Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode cont...原创 2019-04-17 14:25:13 · 170 阅读 · 0 评论 -
LeetCode: 500 Keyboard Row (easy)
题目: Given a List of words, return the words that can be typed using letters ofalphabeton only one row's of American keyboard like the image below. Example 1: Input: ["Hello", "Alaska", "Dad", ...原创 2019-04-17 14:25:19 · 141 阅读 · 0 评论 -
LeetCode: 485 Max Consecutive Ones(easy)
题目: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecut...原创 2019-04-18 10:20:22 · 272 阅读 · 0 评论 -
LeetCode: 520 Detect Capital(easy)
题目: Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in ...原创 2019-04-18 10:20:14 · 166 阅读 · 0 评论 -
LeetCode: 453 Minimum Moves to Equal Array Elements(easy) C++
题目: 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]...原创 2018-12-14 11:24:24 · 155 阅读 · 0 评论 -
LeetCode: 455 Assign Cookies(easy) C++
题目: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of ...原创 2018-12-14 11:29:24 · 191 阅读 · 0 评论 -
LeetCode: 383 Ransom Note(easy) C++
题目: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines...原创 2018-12-14 11:30:57 · 260 阅读 · 0 评论 -
LeetCode: 171 Excel Sheet Column Number(easy) C++
题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z ->...原创 2018-12-14 11:32:30 · 149 阅读 · 0 评论 -
LeetCode: 598 Range Addition II(easy) C++
题目: Given an m * n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is represented by an array with two positive integers...原创 2018-12-14 11:34:10 · 258 阅读 · 0 评论 -
LeetCode: 492 Construct the Rectangle(easy) C++
题目: or a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose leng...原创 2018-12-14 11:36:07 · 173 阅读 · 0 评论 -
LeetCode: 283 Move Zeroes(easy) C++
题目: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling yo...原创 2018-12-14 11:37:44 · 161 阅读 · 0 评论 -
LeetCode: 389 Find the Difference(easy) C++
题目: Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was...原创 2018-12-14 11:39:20 · 152 阅读 · 0 评论 -
LeetCode: 669 Trim a Binary Search Tree(easy) C++
题目: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so t...原创 2018-12-14 11:40:39 · 172 阅读 · 0 评论 -
LeetCode: 371 Sum of Two Integers(easy)
题目: Calculate the sum of two integersaandb, but you arenot allowedto use the operator+and-. Example: Givena= 1 andb= 2, return 3. 代码: 使用移位来计算,用异或求不带进位的和,用与并左移1位来算进位,然后将两者相加。 class S...原创 2019-04-18 10:20:04 · 144 阅读 · 0 评论 -
LeetCode: 258 Add Digits(easy)
题目: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit. For example: Givennum = 38, the process is like:3 + 8 = 11,1 + 1 = 2. Since2has only on...原创 2019-04-18 10:19:58 · 149 阅读 · 0 评论 -
LeetCode: 448 Find All Numbers Disappeared in an Array(easy)
题目: Given an array of integers where 1 ≤ a[i] ≤n(n= size of array), some elements appear twice and others appear once. Find all the elements of [1,n] inclusive that do not appear in this array. ...原创 2019-04-18 10:19:44 · 173 阅读 · 0 评论 -
LeetCode: 226 Invert Binary Tree(easy)
题目: Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 代码: 自己的(递归实现): /** * Definition for a binary tree node. * str...原创 2019-04-18 10:19:50 · 159 阅读 · 0 评论 -
LeetCode: 476 Number Complement(easy)
题目: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range ...原创 2019-04-16 13:09:10 · 158 阅读 · 0 评论
分享