![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode刷题笔记
hellodake
这个作者很懒,什么都没留下…
展开
-
[leetcode]14.Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string"".Example 1:Input: ["flower","flow","flight"]Output:...原创 2020-01-20 17:32:12 · 189 阅读 · 0 评论 -
[leetcode]94. Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Solution:/** * Definition for a binary tree n...原创 2019-06-28 10:10:15 · 101 阅读 · 0 评论 -
[leetcode]46. Permutations
Given a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]Solution:全排列。cl...原创 2019-07-02 16:36:30 · 61 阅读 · 0 评论 -
[leetcode]22. Generate Parentheses
Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())"...原创 2019-07-11 16:31:00 · 74 阅读 · 0 评论 -
[leetcode]206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursiv...原创 2019-07-16 17:01:48 · 123 阅读 · 0 评论 -
[leetcode]238. Product of Array Except Self
Given an arraynumsofnintegers wheren> 1, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Example:Input: [1,2,3,4]Output: ...原创 2019-07-11 19:48:00 · 79 阅读 · 0 评论 -
[leetcode]237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list --head =[4,5,1,9], which looks like following:Example 1:Input: ...原创 2019-07-16 20:02:23 · 87 阅读 · 0 评论 -
[leetcode]347. Top K Frequent Elements
Given a non-empty array of integers, return thekmost frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]Note:You ...原创 2019-07-15 14:51:20 · 70 阅读 · 0 评论 -
[leetcode]78. Subsets
Given a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3], [1...原创 2019-08-16 16:34:56 · 115 阅读 · 0 评论 -
[leetcode]412. Fizz Buzz
Write a program that outputs the string representation of numbers from 1 ton.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. Fo...原创 2019-06-28 09:53:33 · 94 阅读 · 0 评论 -
[leetcode]136. Single Number
Given anon-emptyarray of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...原创 2019-06-27 15:29:41 · 76 阅读 · 0 评论 -
[leetcode]大可日常打卡2
804. Unique Morse Code Words 先把所有的字母以及对应的morse code存储到map里面,然后对于words的每一个,把对应的transformation存储到一个hashmap里面,要是里面有对应的转换的话,就continue;没有的话就添加,返回transformation这个map的size就好。import java.util.HashMap;clas...原创 2018-07-01 14:39:40 · 157 阅读 · 0 评论 -
[leetcode]大可日常打卡-树
687. Longest Univalue Path 一开始非常没有思路。看了解析以后,找到了思路,把长度看作是从一个节点向左右子树延伸出去的两个箭头,如果箭头上的值等于节点的值,那么那么路径的长度就加1。然后刚开始写出的代码分别计算两边的,然后加起来。226. 翻转二叉树 ...原创 2018-07-05 21:32:21 · 150 阅读 · 0 评论 -
[leetcode]大可日常打卡1
344. Reverse Stringclass Solution { public String reverseString(String s) { if(s==null||s.length()==0){ return s; } StringBuilder sb=new StringBuilder(); for(int i=...原创 2018-06-29 14:53:46 · 118 阅读 · 0 评论 -
[leetcode]1038. Binary Search Tree to Greater Sum Tree
Given the root of a binarysearchtree with distinct values, modify it so that everynodehas a new value equal to the sum of the values of the original tree that are greater than or equal tonode.val...原创 2019-06-25 17:16:44 · 217 阅读 · 0 评论 -
[leetcode]344. Reverse String
Write a function that reverses a string. The input string is given as an array of characterschar[].Do not allocate extra space for another array, you must do this bymodifying the input arrayin-pl...原创 2019-06-26 09:49:12 · 65 阅读 · 0 评论 -
[leetcode]807.Max Increase to Keep City Skyline
In a 2 dimensional arraygrid, each valuegrid[i][j]represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amountscan...原创 2019-06-24 09:15:35 · 115 阅读 · 0 评论