![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
hozhangel
这个作者很懒,什么都没留下…
展开
-
192. Word Frequency(shell)
看到shell没几道题,那就把shell先刷了吧Write a bash script to calculate the frequency of each word in a text file words.txt.For simplicity sake, you may assume:words.txt contains only lowercase characters and ...原创 2017-10-27 21:31:00 · 170 阅读 · 0 评论 -
7、Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function should re...原创 2017-10-29 20:01:00 · 172 阅读 · 0 评论 -
258. Add Digits
看眼缘随机拿了一道不难的题https://leetcode.com/problems/add-digits/description/ Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = ...原创 2017-10-27 22:18:00 · 84 阅读 · 0 评论 -
33. Search in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found i...原创 2017-11-16 18:59:00 · 88 阅读 · 0 评论 -
37. Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku puzzle......原创 2017-11-17 16:31:00 · 107 阅读 · 0 评论 -
36. Valid Sudoku数独判断
题目:数独填写正确判断https://leetcode.com/problems/valid-sudoku/description/Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty...原创 2017-11-17 15:44:00 · 143 阅读 · 0 评论 -
35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. -------------------------------------------------------------------------------------------------------------------...原创 2017-11-16 20:20:00 · 73 阅读 · 0 评论 -
34. Search for a Range
Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the targ...原创 2017-11-16 19:59:00 · 5352 阅读 · 0 评论 -
32. Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which ...原创 2017-11-16 16:33:00 · 90 阅读 · 0 评论 -
31. Next Permutation下一个排列
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o...原创 2017-11-16 09:46:00 · 132 阅读 · 0 评论 -
30. Substring with Concatenation of All Words找出串联所有词的子串
题目:https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indic...原创 2017-11-15 19:44:00 · 181 阅读 · 0 评论 -
29. Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.两个数相除,不使用乘法,除法,求模计算两个数的除法~除法运算:被除数中包含有多少个除数的计算 由于是int类型的除法,因此结果可能超过int的最大值,当超过in...原创 2017-11-14 23:07:00 · 74 阅读 · 0 评论 -
28. Implement strStr()子串匹配
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2 Exam...原创 2017-11-14 22:37:00 · 70 阅读 · 0 评论 -
27. Remove Element
Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-plac...原创 2017-11-14 22:31:00 · 97 阅读 · 0 评论 -
8、 String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input case...原创 2017-10-29 20:35:00 · 116 阅读 · 0 评论 -
9、Palindrome Number回文数
Determine whether an integer is a palindrome. Do this without extra space. 判断是否是回文数。.如:98789返回true。提示:1)负数不是回文数,如-123 ‘-’不等于‘3’2)不能使用额外空间的意思是,不管输入的是什么,空间复杂度保持常数。还有如果是定义一个int类型的数,使用的空间是OK的,因为固...原创 2017-11-06 19:31:00 · 112 阅读 · 0 评论 -
6、字符串循环对角线结构ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I...原创 2017-10-27 17:03:00 · 224 阅读 · 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. ...原创 2017-10-26 21:45:00 · 74 阅读 · 0 评论 -
LeetCode摸索
图样图森破今天发现LeetCode有solution,而且,点开solution之后,这时点击屏幕大概右上角view in article,里面有具体详解。java或python或。。的代码虽然不一定就好理解,但是实在不会做的时候,没有思路的时候可以看一哈...原创 2017-10-26 21:30:00 · 121 阅读 · 0 评论 -
4、两个有序序列的中位数。Median of Two Sorted Arrays
题源: https://leetcode.com/problemset/all/ 第四题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 ...原创 2017-10-26 20:30:00 · 280 阅读 · 0 评论 -
18. 4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution set...原创 2017-11-10 19:01:00 · 79 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit strin...原创 2017-11-10 17:15:00 · 86 阅读 · 0 评论 -
16. 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly...原创 2017-11-10 16:26:00 · 117 阅读 · 0 评论 -
15、3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain dup...原创 2017-11-09 20:11:00 · 178 阅读 · 0 评论 -
13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.leetcode上已有的解决方法:1、https://leetcode.com/problems/roman-to-integer/discuss/public int...原创 2017-11-08 20:06:00 · 75 阅读 · 0 评论 -
14. Longest Common Prefix最大前缀
https://leetcode.com/problems/longest-common-prefix/description/Write a function to find the longest common prefix string amongst an array of strings.找出一堆字符串,相同前缀,如:abcdhewuhf,abcjjee,abcd 的最大前缀是a...原创 2017-11-08 20:36:00 · 79 阅读 · 0 评论 -
12. Integer to Roman 整数转化为罗马数字
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.罗马数字: 基本字符 I V X L C ...原创 2017-11-08 19:21:00 · 226 阅读 · 0 评论 -
11. Container With Most Water
2017-11-07 21:58:22https://leetcode.com/problems/container-with-most-water/description/Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertica...原创 2017-11-08 18:52:00 · 89 阅读 · 0 评论 -
10. Regular Expression Matching正则表达式
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input s...原创 2017-11-07 21:32:00 · 86 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying th...原创 2017-11-14 22:26:00 · 75 阅读 · 0 评论 -
25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of ...原创 2017-11-14 15:19:00 · 89 阅读 · 0 评论 -
46. Permutations
https://leetcode.com/problems/permutations/description/Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], ...原创 2017-12-08 17:14:00 · 111 阅读 · 0 评论 -
47. Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1,1]]...原创 2017-12-12 16:40:00 · 128 阅读 · 0 评论 -
48. Rotate Image
https://leetcode.com/problems/rotate-image/description/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-pla...原创 2017-12-12 18:23:00 · 119 阅读 · 0 评论 -
49. Group Anagrams
Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat原创 2017-12-13 11:18:00 · 131 阅读 · 0 评论 -
50. Pow(x, n)
Implement pow(x, n). 题目:https://leetcode.com/problems/powx-n/description/Example 1:Input: 2.00000, 10Output: 1024.00000 Example 2:Input: 2.10000, 3Output: 9.26100求x的n次方C++https://...原创 2017-12-13 11:52:00 · 119 阅读 · 0 评论 -
86. Partition List
86. Partition ListGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of th...原创 2018-08-11 19:33:00 · 160 阅读 · 0 评论 -
83. Remove Duplicates from Sorted List
83. Remove Duplicates from Sorted List(相似题目:82. Remove Duplicates from Sorted List II)Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input...原创 2018-08-11 19:11:00 · 128 阅读 · 0 评论 -
82. Remove Duplicates from Sorted List II
82. Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2-...原创 2018-08-11 19:05:00 · 113 阅读 · 0 评论 -
61. Rotate List
https://leetcode.com/problems/rotate-list/description/Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL,...原创 2018-08-11 11:05:00 · 117 阅读 · 0 评论