leetcode
Johnsonjjj
这个作者很懒,什么都没留下…
展开
-
Leetcode——494. Target Sum
题目描述You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out how...原创 2019-11-30 11:46:11 · 292 阅读 · 0 评论 -
LeetCode——128. Longest Consecutive Sequence
最近这段时间偷懒了,嘿嘿,好多天没更新博客了。不行,还是要勤快一点才行。 问题描述:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest c原创 2017-09-28 21:46:24 · 323 阅读 · 0 评论 -
LeetCode——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 dictionary words. You may原创 2017-10-19 13:44:51 · 314 阅读 · 0 评论 -
LeetCode——136. Single Number&&137. Single Number II
——Single Number 问题描述:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it w原创 2017-10-11 01:09:39 · 246 阅读 · 0 评论 -
LeetCode——124. Binary Tree Maximum Path Sum
问题描述:Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The原创 2017-10-13 01:46:29 · 307 阅读 · 0 评论 -
LeetCode——138. Copy List with Random Pointer
问题描述:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list. 这道题大致的意思就是,一个链表,它每一个节点除了一个next引用原创 2017-10-13 23:18:14 · 228 阅读 · 0 评论 -
LeetCode——141. Linked List Cycle && 142. Linked List Cycle II
今天再次推出一套组合题。 首先是:141.Linked List Cycle 问题描述:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space? 题目大致的意思就是给你一个链表,判断它里面是否含有环,有的话返回true,没有的原创 2017-10-15 01:38:31 · 262 阅读 · 0 评论 -
LeetCode——152. Maximum Product Subarray
问题描述:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest p原创 2017-10-26 21:03:33 · 240 阅读 · 0 评论 -
LeetCode——376. Wiggle Subsequence
最近事情有点多,所以中间隔了很长时间没有写leetcode,也就很长时间没有更新博客了,望谅解哈。 今天重新开始写动态规划的题,遇到了一道非常有意思的题,必须要与大家分享一下。 问题描述:A sequence of numbers is called a wiggle sequence if the differences between successive numbers stric原创 2017-11-24 23:04:43 · 301 阅读 · 0 评论 -
LeetCode——99. Recover Binary Search Tree
问题描述:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a c原创 2017-09-18 16:03:42 · 483 阅读 · 0 评论 -
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.Follow up:Did you use extra space?A straight forward solution using O(mn) space is probably a bad ide原创 2017-09-18 00:08:04 · 482 阅读 · 0 评论 -
LeetCode——79. Word Search
问题描述:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically原创 2017-09-08 23:29:52 · 279 阅读 · 0 评论 -
LeetCode——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 exist in the tree. 这道题大致的意思就是,它会给你一棵二叉树的前序遍历序列和中序遍历序列,然后要你根据这两个序列来重原创 2017-09-04 23:22:49 · 421 阅读 · 0 评论 -
LeetCode——106. Construct Binary Tree from Inorder and Postorder Traversal
问题描述: Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree. 题目大致的意思是给出一棵二叉树的中序遍历结果序列和后序遍历结果序列,让你根据这两个序列数组重新创建这棵树原创 2017-09-05 00:25:13 · 193 阅读 · 0 评论 -
LeetCode——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. 这道题大致的意思是在一棵二叉树上,求根节点到叶子结点的最远层数(最远距离原创 2017-09-05 21:47:34 · 254 阅读 · 0 评论 -
LeetCode——60. Permutation Sequence
问题描述:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):1、"123"2、"132"3、"213"4、"23原创 2017-09-14 01:06:23 · 278 阅读 · 0 评论 -
LeetCode——111. Minimum Depth of Binary Tree
问题描述:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 这道题大致的意思是在一棵二叉树中求根节点到叶子结点的最小层数(最小距离)原创 2017-09-05 21:39:12 · 240 阅读 · 0 评论 -
LeetCode——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 tree [3,9,20,null,null,15,7], 3 / \9 20 / \ 1原创 2017-09-06 23:22:49 · 266 阅读 · 0 评论 -
LeetCode——111. Minimum Depth of Binary Tree
问题描述: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], 3 / \9 20 / \ 1原创 2017-09-06 23:30:39 · 207 阅读 · 0 评论 -
LeetCode——72. Edit Distance
问题描述:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:原创 2017-09-14 21:26:13 · 357 阅读 · 0 评论 -
LeetCode——1. Two Sum
嘿嘿,这是我的第一篇博客,希望大家能够多多支持,多多指教。 这道题是LeetCode上的第一道题,问题描述是这样的: 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 wo原创 2017-08-22 23:54:10 · 185 阅读 · 0 评论