自定义博客皮肤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 278

原创 [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 273

原创 [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 167

原创 [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 163

原创 [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 230

原创 [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 184

原创 [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 197

原创 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 282

原创 LeetCode刷题日记(Day21)

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

2019-04-02 15:22:29 167

原创 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 192

原创 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 391

原创 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 = 3 Output: [5,6,7,1,2,3,4] Explanation: rotat...

2019-03-30 23:28:12 202

原创 LeetCode刷题日记(Day17)

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

2019-03-26 18:47:49 225

原创 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 238

原创 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 288

原创 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 211

原创 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 291

原创 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 244

原创 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 219

原创 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 496

原创 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 256

原创 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 285

原创 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 263

原创 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 277

原创 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 278

原创 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 377

原创 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 359

原创 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 320

原创 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 363

空空如也

空空如也

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

TA关注的人

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