![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
一颗烂葱
为了未来
展开
-
238. Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n). For原创 2017-02-06 18:30:11 · 212 阅读 · 0 评论 -
1. Two Sum
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 would have exactly one solution.Example: Given nums = [2, 7, 1原创 2017-01-18 17:11:48 · 242 阅读 · 0 评论 -
283. Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your fu原创 2017-01-18 20:17:49 · 255 阅读 · 0 评论 -
485. Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutiv原创 2017-01-18 23:15:21 · 277 阅读 · 0 评论 -
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 digit. Add the two numbers and ret原创 2017-02-09 22:23:44 · 382 阅读 · 0 评论 -
LeetCode_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.这是一个最长回文子序列的问题,有以下几种解法1.动态规划我在做题时是用这种解法,时间复杂度为o(n^2)。式子不难列出:dp[i][j] = s[i]==s[j] &&原创 2017-02-19 17:39:26 · 353 阅读 · 0 评论 -
169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always原创 2017-01-20 21:49:39 · 231 阅读 · 0 评论 -
209. Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead. For example, given the array原创 2017-01-21 20:48:57 · 201 阅读 · 0 评论