
机考
TalentedYZ
为了九推,加加油!
展开
-
LeetCode 15. 3Sum
LeetCode 15. 3Sum题目描述:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note:...原创 2018-08-14 10:51:18 · 108 阅读 · 0 评论 -
LeetCode 873. Length of Longest Fibonacci Subsequence
LeetCode 873. Length of Longest Fibonacci Subsequence题目描述:A sequence X_1, X_2, …, X_n is fibonacci-like if:n >= 3X_i + X_{i+1} = X_{i+2} for all i + 2 <= nGiven a strictly increasi...原创 2018-08-19 15:19:06 · 579 阅读 · 0 评论 -
LeetCode 22. Generate Parentheses
LeetCode 22. Generate Parentheses题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ ...原创 2018-08-19 16:57:28 · 134 阅读 · 0 评论 -
LeetCode 131. Palindrome Partitioning
LeetCode 131. Palindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input...原创 2018-08-22 16:32:58 · 153 阅读 · 0 评论 -
LeetCode 48. Rotate Image(矩阵旋转相关)
LeetCode 48. Rotate ImageYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have ...原创 2018-08-23 11:17:15 · 182 阅读 · 0 评论 -
LeetCode 24. Swap Nodes in Pairs(链表交换操作)
LeetCode 24. Swap Nodes in Pairs题目描述:Given a linked list, swap every two adjacent nodes and return its head.Example:Given 1-&gt;2-&gt;3-&gt;4, you should return the list as 2-&gt;1-&gt;4...原创 2018-08-20 17:03:24 · 133 阅读 · 0 评论 -
leetcode 10 Regular Expression Matching
leetcode 10 Regular Expression Matching题目描述:Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character. ...原创 2018-08-27 21:10:21 · 853 阅读 · 0 评论 -
LeetCode 46. Permutations(回溯法解决)
LeetCode 46. Permutations题目描述:Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2]...原创 2018-08-20 19:27:57 · 306 阅读 · 0 评论 -
LeetCode 23. Merge k Sorted Lists
LeetCode 23. Merge k Sorted Lists题目描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, ...原创 2018-08-29 17:52:26 · 126 阅读 · 0 评论 -
LeetCode 25. Reverse Nodes in k-Group
LeetCode 25. Reverse Nodes in k-Group题目描述:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal t...原创 2018-08-29 18:36:16 · 144 阅读 · 0 评论 -
LeetCode 30. Substring with Concatenation of All Words
题目描述:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once ...原创 2018-09-18 22:27:01 · 168 阅读 · 0 评论 -
LeetCode 31. Next Permutation
题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possi...原创 2018-09-19 20:08:52 · 119 阅读 · 0 评论 -
LeetCode 91. Decode Ways
LeetCode 91. Decode WaysA message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given a non-empty string contain...原创 2018-08-22 11:39:17 · 162 阅读 · 0 评论 -
LeetCode 2. Add Two Numbers
LeetCode 2. Add Two Numbers题目描述:You 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...原创 2018-08-16 12:04:27 · 124 阅读 · 0 评论 -
LeetCode 65. Valid Number
LeetCode 65. Valid Number题目描述:Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNot原创 2018-08-14 17:10:25 · 143 阅读 · 0 评论 -
LeetCode 73. Set Matrix Zeroes
LeetCode 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 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Outp...原创 2018-08-14 20:31:46 · 109 阅读 · 0 评论 -
LeetCode 21 Merge Two Sorted Lists
LeetCode 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. 翻译: 将两个已经排...原创 2018-08-11 20:45:45 · 157 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
26. Remove Duplicates from Sorted Array题目描述:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra s...原创 2018-08-12 10:36:57 · 131 阅读 · 0 评论 -
27. Remove Element
27. Remove Element跟26题类似,没什么营养 在重新确定数组长度时,除了erase还可以用base迭代器和resize函数操作以下,即直接nums.resize(base)class Solution {public: int removeElement(vector<int>& nums, int val) { ...原创 2018-08-12 10:46:09 · 167 阅读 · 0 评论 -
28. Implement strStr()
28. Implement strStr()题目描述:Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello",...原创 2018-08-12 11:12:05 · 118 阅读 · 0 评论 -
38. Count and Say
38. Count and Say题目描述:The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as...原创 2018-08-12 12:11:17 · 1193 阅读 · 0 评论 -
LeetCode 98. Validate Binary Search Tree
LeetCode 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...原创 2018-08-15 12:24:44 · 206 阅读 · 0 评论 -
LeetCode 8. String to Integer (atoi)
LeetCode 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-white...原创 2018-08-13 17:57:55 · 111 阅读 · 0 评论 -
LeetCode 127. Word Ladder
题目描述:Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed ...原创 2018-08-16 10:28:24 · 437 阅读 · 0 评论 -
DFS 和 BFS 写在124题后
深度优先搜索(Depth First Search)和广度优先搜索(Breadth First Search)深度优先遍历图的方法是,从图中某顶点v出发(百度百科): (1)访问顶点v; (2)依次从v的未被访问的邻接点出发,对图进行深度优先遍历;直至图中和v有路径相通的顶点都被访问; (3)若此时图中尚有顶点未被访问,则从一个未被访问的顶点出发,重新进行深度优先遍历,直到图中所...原创 2018-08-16 10:30:32 · 150 阅读 · 0 评论