leetcode
Carmen_W
这个作者很懒,什么都没留下…
展开
-
Tree(easy)八道题
101. Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie,symmetric around its center).Note: Bonus points if you could solve it both recursively anditeratively.Recursi...原创 2019-01-23 19:01:55 · 252 阅读 · 0 评论 -
Array(easy)七道题
Two Sum(easy)Given an array of integers, return indices of the two numbers suchthat they add up to a specific target.Given an array of integers,return indices of the two numbers such that they a...原创 2019-01-23 14:23:56 · 409 阅读 · 0 评论 -
Hash Table-------(easy四道题)(medium五道题)
1. Two Sum(easy)Given an array of integers, return indices of the two numbers suchthat they add up to a specific target.Given an array of integers,return indices of the two numbers such that they ...原创 2019-01-23 15:16:47 · 207 阅读 · 0 评论 -
Linked List(easy五道题)(medium四道题)
206. Reverse Linked ListReverse a singly linked list.Example:Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULLFollow up:A lin原创 2019-01-23 15:46:10 · 386 阅读 · 0 评论 -
Two Points(easy三道题)(medium七道题)
283. Move ZeroesGiven an array nums, write a function to move all 0’s to the end of itwhile maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12] Output: [1,3,12,0,...原创 2019-01-23 16:01:58 · 332 阅读 · 0 评论 -
String(easy一道题)(medium六道题)
20. Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed ...原创 2019-01-23 16:07:02 · 262 阅读 · 0 评论 -
Divide and Conquer(easy两道)(medium两道)
169. Majority ElementGiven an array of size n, find the majority element. The majorityelement is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the...原创 2019-01-23 16:10:03 · 340 阅读 · 0 评论 -
Dynamic Programming(easy四道题)(medium十五道题)
53. Maximum SubarrayGiven an integer array nums, find the contiguous subarray (containingat least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],...原创 2019-01-23 16:33:04 · 966 阅读 · 0 评论 -
Stack(easy两道题)(medium两道)
20. Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed ...原创 2019-01-23 16:41:03 · 232 阅读 · 0 评论 -
Bit Manipulation(easy)三道题
136. Single NumberGiven a non-empty array of integers, every element appears twiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could youimple...原创 2019-01-23 16:51:18 · 320 阅读 · 0 评论 -
leetcode 141_206_24_24_142_20_232_225_703_239_242_15_98_236_235_50_169_122
141/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public cl...原创 2019-03-20 17:47:39 · 476 阅读 · 0 评论 -
时间空间效率的平衡4+时间效率5
1. 丑数题目描述把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。链接:https://www.nowcoder.com/questionTerminal/6aa9e04fc3794f68acf8778237ba065b来源:牛客网class Sol...原创 2019-01-25 10:36:01 · 444 阅读 · 0 评论 -
Sort(medium三道题)
56. Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.A simple Java solution:The idea is to sort the intervals by their starting points. Then, we take the first in...原创 2019-01-25 10:34:53 · 286 阅读 · 0 评论 -
Dipth-First Search(easy)两道题
101. Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie,symmetric around its center).Note: Bonus points if you could solve it both recursively anditeratively.Recursi...原创 2019-01-24 10:27:11 · 607 阅读 · 0 评论 -
Breadth-First Search(easy一道题)(medium四道题)
101. Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie,symmetric around its center).Note: Bonus points if you could solve it both recursively anditeratively.Recursi...原创 2019-01-24 10:27:52 · 332 阅读 · 0 评论 -
Design---Union Find---Graph---Topological Sort---Trie---Queue
155. Min StackDesign a stack that supports push, pop, top, and retrieving theminimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack....原创 2019-01-24 10:28:34 · 181 阅读 · 0 评论 -
Array(medium)二十道题(上)
11. Container With Most WaterGiven n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at...原创 2019-01-24 10:28:46 · 290 阅读 · 0 评论 -
Array(medium)二十道题(下)
64. Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move eith...原创 2019-01-24 10:28:58 · 339 阅读 · 0 评论 -
Math(medium两道)
2. Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two ...原创 2019-01-24 10:29:09 · 291 阅读 · 0 评论 -
Binary Search(medium五道)
33. Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a...原创 2019-01-24 10:29:20 · 180 阅读 · 0 评论 -
Backtracking(medium六道题)
17. Letter Combinations of a Phone NumberGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (...原创 2019-01-24 10:29:37 · 259 阅读 · 0 评论 -
Heap(medium两道题)
215. Kth Largest Element in an ArrayFind the kth largest element in an unsorted array. Note that it is thekth largest element in the sorted order, not the kth distinct element.Note:You may assum...原创 2019-01-24 10:29:49 · 190 阅读 · 0 评论 -
Greedy(medium三道题)
55. Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.De...原创 2019-01-24 10:29:59 · 261 阅读 · 0 评论 -
LeetCode 102_104_111_22_69_208_191_338_231
102. Binary Tree Level Order TraversalBFS iterative:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode...原创 2019-03-21 23:37:13 · 314 阅读 · 0 评论