自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 [LeetCode刷题日记(Day25)]:Course Schedule

Problem 207. Course Schedule题目描述There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take cou...

2019-04-11 12:55:55 173

原创 [LeetCode刷题日记(Day24)]:Evaluate Reverse Polish Notation

Problem 150. Evaluate Reverse Polish Notation题目描述Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe...

2019-04-05 17:47:30 173

原创 [LeetCode刷题日记(Day24)]:Word Break

Problem 139. Word Break题目描述Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more...

2019-04-05 16:59:09 106

原创 [LeetCode刷题日记(Day24)]:Gas Station

Problem 134. Gas Station题目描述There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas t...

2019-04-05 16:01:31 103

原创 [LeetCode刷题日记(Day24)]:Palindrome Partitioning

Problem 131. Palindrome Partitioning题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input: ...

2019-04-05 15:26:48 108

原创 [LeetCode刷题日记(Day23)]:Binary Tree Level Order Traversal

Problem 102. Binary Tree Level Order Traversal题目描述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 tr...

2019-04-04 13:48:39 108

原创 [LeetCode刷题日记(Day23)]:Validate Binary Search Tree

Problem 98. Validate Binary Search Tree题目描述Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...

2019-04-04 13:04:54 104

原创 LeetCode刷题日记(Day22)

Problem 242. Valid Anagram题目描述Given two strings s and t , write a function to determine if t is an anagram of s.Example:Input: s = "anagram", t = "nagaram"Output: true解题思路要判断一个字符串是否由另一个字符串...

2019-04-03 13:10:46 160

原创 LeetCode刷题日记(Day21)

Problem 234. Palindrome Linked List题目描述Given a singly linked list, determine if it is a palindrome.Example:Input: 1->2->2->1Output: true解题思路要判断一个链表是否是回文链表,且要求时间复杂度和空间复杂度分别为 O(n) 和...

2019-04-02 15:22:29 121

原创 LeetCode刷题日记(Day20)

Problem 202. Happy Number题目描述Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the nu...

2019-04-01 20:45:16 143

原创 LeetCode刷题日记(Day19)

Problem 198. House Robber题目描述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 ea...

2019-03-31 23:41:06 231

原创 LeetCode刷题日记(Day18)

Problem 189. Rotate Array题目描述Given an array, rotate the array to the right by k steps, where k is non-negative.Example:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotat...

2019-03-30 23:28:12 144

原创 LeetCode刷题日记(Day17)

Problem 172. Factorial Trailing Zeroes题目描述Given an integer n, return the number of trailing zeroes in n!.Example:Input: 5Output: 1Explanation: 5! = 120, one trailing zero.解题思路本题要求的是 n 的阶乘...

2019-03-26 18:47:49 151

原创 LeetCode刷题日记(Day16)

Problem 136. Single Number题目描述Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. C...

2019-03-26 13:01:28 186

原创 LeetCode刷题日记(Day15)

Problem 118. Pascal’s Triangle题目描述Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly ab...

2019-03-25 21:07:08 170

原创 LeetCode刷题日记(Day14)

Problem 105. Construct Binary Tree from Preorder and Inorder Traversal题目描述Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exi...

2019-03-24 11:39:41 138

原创 LeetCode刷题日记(Day13)

Problem 88. Merge Sorted Array题目描述Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m an...

2019-03-24 09:09:59 169

原创 LeetCode刷题日记(Day12)

Problem 78. Subsets题目描述Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3...

2019-03-18 21:23:42 195

原创 LeetCode刷题日记(Day11)

Problem 73. Set Matrix Zeroes题目描述Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Example:Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5]]Output: [...

2019-03-16 16:48:49 172

原创 LeetCode刷题日记(Day10)

Problem 56. Merge Intervals题目描述Given a collection of intervals, merge all overlapping intervals.Example:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since inte...

2019-03-15 20:40:34 351

原创 LeetCode刷题日记(Day9)

Problem 49. Group Anagrams题目描述Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan",

2019-03-15 15:05:45 194

原创 LeetCode刷题日记(Day8)

Problem 33. Search in Rotated Sorted Array题目描述Suppose 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]).Y...

2019-03-14 13:15:13 190

原创 LeetCode刷题日记(Day7)

Problem 21. Merge Two Sorted Lists题目描述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.解题思路此题较简单,创建一...

2019-03-13 13:44:00 211

原创 LeetCode刷题日记(Day6)

Problem 19. Remove Nth Node From End of List题目描述Given a linked list, remove the n-th node from the end of list and return its head.解题思路要删除链表中倒数第 n 个节点,可以采取双指针的办法,一个快指针 cur,一个慢指针 pre,其中快指针 cur ...

2019-03-12 17:44:00 176

原创 LeetCode刷题日记(Day5)

Problem 14. Longest Common Prefix题目描述Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.解题思路本题采用的是迭代...

2019-03-11 17:07:49 229

原创 LeetCode刷题日记(Day4)

Problem 8. String to Integer (atoi)题目描述Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace c...

2019-03-09 13:33:29 255

原创 LeetCode刷题日记(Day3)

Problem 5. Longest Palindromic Substring题目描述Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.解题思路:回文子串,即正序和倒序输出结果都一样的字符串。例如字符串...

2019-03-08 11:10:04 245

原创 LeetCode刷题日记(Day2)

Problem 3. Longest Substring Without Repeating Characters 题目描述Given a string, find the length of the longest substring without repeating characters.解题思路:定义int变量len,初始化为0,表示最长子串;int变量left表...

2019-03-07 22:14:36 268

原创 LeetCode刷题日记(Day1)

Problem 1. Two Sum 解题思路:创建map<int, int>变量m,对传入的nums进行遍历,并将遍历过的nums[i]存入到m当中。创建变量temp,对nums再进行一次遍历,将target - nums[i]赋值给temp,并判断temp是否在m中已有。如果有,则找到解。时间复杂度分析:由于对nums进行一次遍历的代价为O(n),且每个num...

2019-03-06 21:58:42 285

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除