
Leetcode
hahahahhahello
这个作者很懒,什么都没留下…
展开
-
[LeetCode] 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 ...原创 2018-11-13 17:08:10 · 414 阅读 · 0 评论 -
[LeetCode ] Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at ...原创 2018-12-05 16:24:01 · 220 阅读 · 0 评论 -
[LeetCode ] 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 hous...原创 2018-12-05 16:20:32 · 195 阅读 · 0 评论 -
[LeetCode ] Weekly Contest 112
Minimum Increment to Make Array UniqueGiven an array of integers A, a move consists of choosing any A[i], and incrementing it by 1.Return the least number of moves to make every value in A unique...原创 2018-11-27 11:14:47 · 239 阅读 · 0 评论 -
[LeetCode ] Best Time to Buy and Sell Stock系列题解
这一系列的题目的基本模型是给出n天每天股票的价格,可以在任意一天买股票,在之后的任意一天把股票卖出,赚取差价,限制是手中最多有一张股票,必选把手中的股票卖掉才能再买股票。求最大获利。题目1:Best Time to Buy and Sell Stock这是最简单的一道题,在基本模型的基础上添加了一个限制条件,最多交易一次。我们从第一天开始遍历,维护一个已经遍历过的股票的最小价格mi...原创 2018-11-24 21:02:21 · 473 阅读 · 0 评论 -
[LeetCode ] Minimum Absolute Difference in BST
Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input: 1 \ 3 / 2Output:1Explanation:T...原创 2018-11-20 11:04:41 · 211 阅读 · 0 评论 -
[LeetCode ] Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assum...原创 2018-11-22 14:14:25 · 265 阅读 · 0 评论 -
[LeetCode ] Long Pressed Name
Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.You examine the typed characte...原创 2018-11-17 10:00:31 · 264 阅读 · 0 评论 -
[LeetCode ] H-Index
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A s...原创 2018-11-17 09:18:48 · 319 阅读 · 0 评论 -
[LeetCode ] Basic Calculator
Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty s...原创 2018-11-22 09:02:41 · 286 阅读 · 0 评论 -
[LeetCode] 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.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note:You...原创 2018-11-16 15:31:27 · 199 阅读 · 0 评论 -
[LeetCode ] Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: f...原创 2018-11-16 14:45:39 · 182 阅读 · 0 评论 -
[LeetCode] 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)).You may assume nums1 and ...原创 2018-11-14 19:44:50 · 248 阅读 · 0 评论 -
[LeetCode] Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:...原创 2018-11-14 19:09:59 · 268 阅读 · 0 评论 -
[LeetCode ] Weekly Contest 111
Valid Mountain ArrayGiven an array A of integers, return true if and only if it is a valid mountain array.Recall that A is a mountain array if and only if:A.length >= 3 There exists some i...原创 2018-11-18 19:07:33 · 380 阅读 · 0 评论 -
[LeetCode ]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 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.E...原创 2018-11-15 19:12:10 · 294 阅读 · 0 评论 -
Leetcode题目汇总(持续更新)
一开始想写Pat甲上的题,但Pat甲上的题考查太单一了,大部分是一些数据结构、图的题,听说Leetcode不错,就刷这个了,发现这个OJ和其它的OJ不太一样,以函数的形式提交题目,样例不能在本地测了,以下每一道题的代码都会有C和Java两份,其实刷算法题用什么语言都大同小异。更新的会非常慢。。。。。1.Two Sum2.Add Two Numbers3.Longest Substrin...原创 2018-11-13 18:38:27 · 751 阅读 · 0 评论 -
[LeetCode] 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, and you may not use the same...原创 2018-11-13 17:13:34 · 227 阅读 · 0 评论 -
[LeetCode ] Weekly Contest 113
Largest Time for Given DigitsGiven an array of 4 digits, return the largest 24 hour time that can be made.The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00, a ti...原创 2018-12-03 16:29:04 · 260 阅读 · 0 评论