LeetCode
热爱满天星
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode - 111. Minimum Depth of Binary Tree
Description 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. Note: A leaf is a node wi...原创 2018-09-04 08:39:29 · 207 阅读 · 0 评论 -
LeetCode - 198. House Robber
Description 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 ad...原创 2018-10-08 09:01:40 · 303 阅读 · 0 评论 -
最大栈的实现
问题描述 一个栈stack,具有push和pop操作,其时间复杂度皆为O(1)。 设计算法max操作,求栈中的最大值,该操作的时间复杂度也要求为O(1)。 可以修改栈的存储方式,push,pop的操作,但是要保证O(1)的时间复杂度,空间时间复杂度无要求 思路 比较容易想到的是除了原始数据栈之外,再声明一个存放最大值的栈。每次加入数据后,都判断求得最新的最大值,然后把当前的最大值存入到maxSta...原创 2018-10-12 16:43:24 · 1114 阅读 · 0 评论 -
LeetCode - 202. Happy Number
Description Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of th...原创 2018-10-04 21:30:11 · 316 阅读 · 0 评论 -
LeetCode - 203. Remove Linked List Elements
Description Remove all elements from a linked list of integers that have value val. Example Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 Code /** * Defin...原创 2018-10-04 20:35:18 · 294 阅读 · 0 评论 -
LeetCode - 3. Longest Substring Without Repeating Characters
Description Given a string, find the length of the longest substring without repeating characters. Example Example 1: Input: “abcabcbb” Output: 3 Explanation: The answer is “abc”, with...原创 2018-09-14 17:10:19 · 243 阅读 · 0 评论 -
LeetCode - 136. Single Number
Description Given a non-empty 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 ...原创 2018-09-13 09:47:21 · 227 阅读 · 0 评论 -
LeetCode - 141. Linked List Cycle
Description Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? Code /** * Definition for singly-linked list. * class ListNode { * ...原创 2018-09-13 09:37:57 · 171 阅读 · 0 评论 -
LeetCode - 171. Excel Sheet Column Number
Description Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example Ex...原创 2018-09-17 22:26:05 · 259 阅读 · 0 评论 -
LeetCode - 122. Best Time to Buy and Sell Stock II
Description 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 ...原创 2018-09-10 09:38:24 · 230 阅读 · 0 评论 -
LeetCode - 168. Excel Sheet Column Title
Description Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ... E...原创 2018-09-16 23:41:22 · 301 阅读 · 0 评论 -
LeetCode - 110. Balanced Binary Tree
Description Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the depth of the two subtrees of every nod...原创 2018-09-03 21:53:17 · 209 阅读 · 0 评论 -
LeetCode - 108. Convert Sorted Array to Binary Search Tree
Description Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the...原创 2018-09-03 16:43:44 · 168 阅读 · 0 评论 -
LeetCode - 125. Valid Palindrome
Description Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palin...原创 2018-09-11 17:53:06 · 193 阅读 · 0 评论 -
LeetCode - 112. Path Sum
Description Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Note: A leaf is a node with no childr...原创 2018-09-05 10:28:58 · 252 阅读 · 0 评论 -
LeetCode - 225. Implement Stack Using Queues
Description Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. empty() – Ret...原创 2018-10-18 14:25:35 · 299 阅读 · 0 评论
分享