
leetcode
子长
这个作者很懒,什么都没留下…
展开
-
169. Majority Element (9月8日)
169. Majority Element169. 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原创 2017-09-08 21:45:10 · 196 阅读 · 0 评论 -
647. Palindromic Substrings
题目:Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consist原创 2017-11-27 17:28:46 · 179 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters
description:leetcode算法第三题 Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3.Given “bbbbb”, the原创 2017-12-17 23:18:59 · 147 阅读 · 0 评论 -
238. Product of Array Except Self
题目 discussion中的解答: class Solution { public: vectorint> productExceptSelf(vectorint>& nums) { vectorint> left(nums.size(), 1); vectorint> right(nums.size(), 1); vect原创 2018-01-11 14:13:29 · 215 阅读 · 0 评论 -
309. Best Time to Buy and Sell Stock with Cooldown
题目 class Solution { public: int maxProfit(vectorint>& prices) { int buy = INT_MIN; int pre_buy; int sell = 0; int pre_sell = 0; for (int i = 0; i < pri转载 2018-01-11 16:24:22 · 211 阅读 · 0 评论 -
11. Container With Most Water
哦?markdown编辑器更新了?啥玩意? 不管不管,完成作业要紧。 题目 leetcode 11 Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two e原创 2018-01-07 22:23:40 · 155 阅读 · 0 评论 -
11. Container With Most Water
19 Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the lin原创 2018-01-08 11:38:47 · 166 阅读 · 0 评论 -
46. Permutations
Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2原创 2018-01-09 20:51:00 · 160 阅读 · 0 评论 -
48. Rotate Image
You 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 to modify the input 2D matrix d转载 2018-01-09 20:59:04 · 147 阅读 · 0 评论 -
4. Median of Two Sorted Arrays
题目题目链接 There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1: nums1 = [1,原创 2017-12-21 13:59:29 · 162 阅读 · 0 评论 -
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.Example:Input: “babad”Output: “bab”Note: “aba” is also a valid answer. Example:Inpu原创 2017-12-18 18:31:02 · 161 阅读 · 0 评论 -
474. Ones and Zeroes
题目:In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.For now, suppose you are a dominator of m 0s and n 1s respectively. On the other原创 2017-12-03 11:04:09 · 192 阅读 · 0 评论 -
406. Queue Reconstruction by Height
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this p原创 2017-10-20 00:37:22 · 225 阅读 · 0 评论 -
62. Unique Paths
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the botto原创 2017-11-08 01:19:01 · 186 阅读 · 0 评论 -
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 each of them is that adjacent houses原创 2017-10-31 23:50:47 · 169 阅读 · 0 评论 -
343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return 1转载 2017-11-10 23:41:30 · 162 阅读 · 0 评论 -
70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive inte原创 2017-11-02 23:42:37 · 167 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi转载 2017-11-02 00:34:05 · 173 阅读 · 0 评论 -
688. Knight Probability in Chessboard
https://leetcode.com/problems/knight-probability-in-chessboard/description/ On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K moves. The rows and col原创 2017-11-04 22:53:42 · 316 阅读 · 0 评论 -
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 return原创 2017-12-08 23:26:47 · 176 阅读 · 0 评论 -
55. Jump Game
98 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 nodes with keys less than the node’s key.原创 2018-01-10 22:12:53 · 161 阅读 · 0 评论