![](https://img-blog.csdnimg.cn/20190927151124774.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
leetcode easy
文章平均质量分 56
LEETCODE EASY 精选
优惠券已抵扣
余额抵扣
还需支付
¥9.90
¥99.00
购买须知?
本专栏为图文内容,最终完结不会低于15篇文章。
订阅专栏,享有专栏所有文章阅读权限。
本专栏为虚拟商品,基于网络商品和虚拟商品的性质和特征,专栏一经购买无正当理由不予退款,不支持升级,敬请谅解。
brenda_zhao
这个作者很懒,什么都没留下…
展开
-
Easy 170题 Two Sum III - Data structure design
Question:Design and implement a TwoSum class. It should support the following operations: add and find.add - Add the number to an internal data structure.find - Find if there exist原创 2016-10-20 06:04:41 · 303 阅读 · 0 评论 -
Easy 205题 Isomorphic Strings
Question:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be rep原创 2016-10-20 05:02:09 · 238 阅读 · 0 评论 -
Easy 198题 House Robber
Question:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that原创 2016-10-19 13:39:53 · 141 阅读 · 0 评论 -
Easy 7题 Reverse Integer
Question:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Solution:用long处理溢出,注意long和int不能相加~我的笨办法public class Solution { public int re原创 2016-10-18 13:31:28 · 173 阅读 · 0 评论 -
Easy 6题 ZigZag Conversion
Question:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H原创 2016-10-18 12:10:10 · 147 阅读 · 0 评论 -
Easy 21题 Merge Two Sorted Lists(必须重刷!!!)
QUESTION:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.SOLUTION/** * Definition for sing原创 2016-10-07 07:44:02 · 179 阅读 · 0 评论 -
Easy 67题 Add Binary
Question:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Solution:public class Solution { public String addBinary(St原创 2016-10-06 09:23:31 · 359 阅读 · 0 评论 -
Easy 38题 Count and Say
Question:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21原创 2016-10-06 06:57:20 · 154 阅读 · 0 评论 -
Easy 102题 Binary Tree Level Order Traversal
Question:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7],原创 2016-10-06 02:45:46 · 144 阅读 · 0 评论 -
Easy 235题 Lowest Common Ancestor of a Binary Search Tree
Question:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor原创 2016-10-03 03:10:32 · 157 阅读 · 0 评论 -
Easy 206题 Reverse Linked List
Question:Reverse a singly linked list.Solution:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } *原创 2016-10-02 03:49:07 · 156 阅读 · 0 评论 -
Easy 125题 Valid Palindrome
Question:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a原创 2016-10-01 06:16:26 · 134 阅读 · 0 评论 -
Easy 169题 Majority Element
Question:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the ma原创 2016-09-29 06:34:01 · 151 阅读 · 0 评论 -
Easy 189题 Rotate Array
Question:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Solution:public class Solution原创 2016-09-28 14:46:26 · 128 阅读 · 0 评论 -
Easy 219题 Contains Duplicate II
Question:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j]and the difference between i and j is at原创 2016-09-26 05:45:05 · 153 阅读 · 0 评论 -
Easy 88题 Merge Sorted Array
Question:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n原创 2016-09-26 05:00:42 · 134 阅读 · 0 评论 -
Easy 118题 Pascal's Triangle (may be not easy too for me)
Question:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]Solution:看了原创 2016-09-25 14:11:23 · 173 阅读 · 0 评论 -
Easy 26题 Remove Duplicates from Sorted Array(BUT NOT EASY)
Question:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do thi原创 2016-09-25 13:34:48 · 160 阅读 · 0 评论 -
Easy 27题 Remove Element
Question:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with const原创 2016-09-22 11:47:06 · 153 阅读 · 0 评论 -
Easy 66题 Plus One
question:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.Solusti原创 2016-09-22 11:29:32 · 165 阅读 · 0 评论 -
Easy 121题 Best Time to Buy and Sell Stock
Question:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share原创 2016-09-16 13:44:29 · 206 阅读 · 0 评论 -
Easy 168题 Excel Sheet Column Title
问题:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB 和上道题类似10原创 2016-08-06 03:01:24 · 271 阅读 · 0 评论 -
Easy 157题 Read N Characters Given Read4
Question:The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it returns 3 if there is only 3 charact原创 2016-10-11 05:59:47 · 127 阅读 · 0 评论 -
Easy 257题 Binary Tree Paths
Question:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1-原创 2016-10-11 04:38:59 · 154 阅读 · 0 评论 -
Easy 278题 First Bad Version
Question:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is develop原创 2016-10-11 03:42:29 · 132 阅读 · 0 评论 -
Easy 217题 Contains Duplicate
Question:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every原创 2016-09-16 12:58:38 · 123 阅读 · 0 评论 -
Easy 1题 Two Sum
问题:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Given原创 2016-09-16 11:27:44 · 182 阅读 · 0 评论 -
Easy 389题 Find the Difference
Question: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原创 2016-09-14 23:42:39 · 187 阅读 · 0 评论 -
Easy 226题 Invert Binary Tree
问题:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/** * Definition for a binary tree node. * struct TreeNode {原创 2016-08-25 23:32:01 · 184 阅读 · 0 评论 -
Easy 171题 Excel Sheet Column Number
问题:Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 原来看面经看到过这道题原创 2016-08-06 01:57:08 · 139 阅读 · 0 评论 -
Easy 350题 Intersection of Two Arrays II
问题:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].与349很像,这个就是直接求交集了,沿用了349题hashtable的方法,记录相同元素个数来处理冲突class原创 2016-08-06 01:52:28 · 178 阅读 · 0 评论 -
Easy 349题 Intersection of Two Arrays
问题:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].先做排序,然后遍历找相同的,做排序才知道可以用c++标准库,但是该方法复杂度太高。class Solution {p原创 2016-08-06 00:45:41 · 186 阅读 · 0 评论 -
Easy 283题 Move Zeroes
题目: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原创 2016-08-05 14:49:49 · 207 阅读 · 0 评论 -
Easy 104题 Maximum Depth of Binary Tree
问题:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.又是一道有思路的题,直接写出答案,但是由于太不考虑复杂度了,报了t原创 2016-07-30 23:20:42 · 254 阅读 · 0 评论 -
Easy 258题 Add Digital
问题:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has o原创 2016-07-30 22:16:26 · 187 阅读 · 0 评论 -
Easy 292题 Nim Game
问题: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原创 2016-07-30 22:00:49 · 197 阅读 · 0 评论 -
Easy 371题 Sum of Two Integers
题目:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.此题一看是完全没有思路的。。。经提示要用异或^和与&和思路和例子看的这个,觉得写的非常好。http://blog.csdn.net/qq508618087/article/details/原创 2016-07-28 18:33:05 · 211 阅读 · 0 评论 -
Easy 101题 Symmetric Tree
Question:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \原创 2016-10-25 04:10:37 · 165 阅读 · 0 评论 -
Easy 8题 String to Integer (atoi)
Question:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the po原创 2016-10-25 07:18:45 · 175 阅读 · 0 评论 -
Easy 237题 Delete Node in a Linked List
Question:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third原创 2016-10-26 03:12:06 · 166 阅读 · 0 评论