# LeetCode题解：Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the...

# LeetCode题解：Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST is mod...

/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ pub...

# LeetCode题解：Maximum Product of Word Lengths

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case lette...

# LeetCode题解：Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3].题意：先序遍历思路：代码：/** * Definition for a...

# LeetCode题解：Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run in line...

# LeetCode题解：Bulb Switcher

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off i...

# LeetCode题解：Best Time to Buy and Sell Stock with Cooldown

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and...

243条 共25页1 2 3 4 5 ... 下一页 尾页
个人资料
• 访问：210864次
• 积分：4464
• 等级：
• 排名：第7960名
• 原创：234篇
• 转载：8篇
• 译文：0篇
• 评论：46条
博客专栏
 LeetCode全题解 文章：104篇 阅读：46608
 Android应用性能优化 文章：3篇 阅读：11956
 为Android实现测试单元难点剖析 文章：8篇 阅读：19220