- 博客(51)
- 收藏
- 关注
原创 mac 单机安装主从数据库+mysqld_multi stop失效的解决办法
mac 单机安装主从数据库参考安装:https://www.jianshu.com/p/30d504d0ee50https://blog.youkuaiyun.com/lxhsjl121/article/details/105326826https://blog.youkuaiyun.com/andyvera/article/details/93140839执行以下命令启动所有实例:mysqld_multi ...
2020-04-24 18:45:47
361
原创 Leetcode 73. Set Matrix Zeroes [medium][java]
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.ExampleSolution 1: brute forceConsiderationUse a boolean matrix to mark if the element has been set t...
2019-07-27 19:36:03
275
原创 Leetcode 70. Climbing Stairs [easy][java]
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive i...
2019-07-23 21:29:50
265
原创 Leetcode 62. Unique Paths [medium][java]
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bot...
2019-07-22 21:09:53
230
原创 Leetcode 56. Merge Intervals [medium][java]
Given a collection of intervals, merge all overlapping intervals.ExampleIgnored CasesNoteThe original array is not sorted, so maybe the latter intervals should put in front of the previous one...
2019-07-22 20:16:48
118
原创 Leetcode 55. Jump Game [medium][java]
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you ...
2019-07-20 21:02:56
164
原创 Leetcode 54. Spiral Matrix [medium][java]
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.ExampleSolution 1: SimulationUse two 1X4 arrays to mark the moving direction of the x and y...
2019-07-20 15:14:08
124
原创 Leetcode 50. Pow(x, n) [medium][java]
Implement pow(x, n), which calculates x raised to the power n (x^n).ExampleSolution 1Considerationdivide n by 2, and recursively call the functionif n is Integer.MIN_VALUE, n = -n will overflow...
2019-07-17 22:10:24
156
原创 Leetcode 49. Group Anagrams [medium][java]
Given an array of strings, group anagrams together.ExampleNOTEKnowledge about map has been forgotten, should be reviewed.Solution 1Considerationuse a map to store the patternsfor each strin...
2019-07-17 20:56:59
122
原创 Leetcode 48. Rotate Image[medium][java]
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-place, which means you have to modify the input 2D matrix dire...
2019-07-16 22:27:35
115
原创 Leetcode 46. Permutations [medium][java]
Given a collection of distinct integers, return all possible permutations.ExampleConsiderationclearly, we should user recursion in this problemOne main point is that arraylist passing by referen...
2019-07-16 21:20:17
118
原创 Leetcode 44. Wildcard Matching [hard][java]
ExampleConsiderationUse two pointer to remember the position of a ‘*’ occurs in the p and the matched position of the string safter matching the whole string s, we should continue iterate p to ...
2019-07-15 21:47:01
121
原创 Leetcode 42. Trapping Rain Water [hard][java]
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Solution 1
2019-07-06 10:53:09
155
原创 Leecode 41. First Missing Positive [hard][java]
Given an unsorted integer array, find the smallest missing positive integer.ExampleSolution 1Time complexity: O(n), space complexity: O(n). Not fulfil the space requirement.class Solution { p...
2019-07-06 10:33:32
151
原创 Leetcode 36. Valid Sudoku [medium][java]
ExampleSolution 1: Brute ForceTime complexity:O(9^2), space complexity: O()class Solution { public boolean isValidSudoku(char[][] board) { //check row for(int i = 0; ...
2019-07-05 22:27:13
117
原创 Leetcode 34. Find First and Last Position of Element in Sorted Array [medium][java]
Given an array of integers nums 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 t...
2019-07-04 21:21:01
295
原创 leetcode 33. Search in Rotated Sorted Array [medium][java]
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 in...
2019-07-03 23:05:02
107
原创 LeetCode 69. Sqrt(x) [easy][java]
Solution 1: Binary searchConsiderationMake two boundary low and high. Initially, let low be 0 and high be num x.Solution 2: Newton’s methodReferenceshttps://blog.youkuaiyun.com/sole_cc/article/deta...
2019-07-03 21:39:04
203
原创 leetcode 66. Plus One [easy][java]
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element ...
2019-07-03 21:27:43
106
原创 Leetcode 53. Maximum Subarray [easy][java]
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.ExampleConsiderationWe use a sum to represent the current s...
2019-07-03 21:08:16
118
原创 Leetcode 29. Divide Two Integers [medium][java]
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividend by divisor.The integer division shoul...
2019-06-29 15:52:12
345
原创 Leetcode 28. Implement strStr() [easy][java] [KMP Solution]
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.ExampleIgnored Cases==Solution 1: iteration ==Time Complexity: O((n-m)...
2019-06-29 14:23:46
166
原创 Leetcode 25. Reverse Nodes in k-Group [hard][java]
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 n...
2019-06-28 20:12:00
110
原创 Leetcode 23. Merge k Sorted Lists [hard][java][in fact, it may be medium]
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.ExampleSolution 1: Brute ForceConsiderationwe use a pre pointer to point to the current node tha...
2019-06-26 22:20:20
127
原创 Leetcode 10. Regular Expression Matching [hard][java]
Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘’.‘.’ Matches any single character.'’ Matches zero or more of the preceding element.The ma...
2019-06-25 22:19:11
215
原创 Leetcode 24. Swap Nodes in Pairs [medium][java]
Given a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes, only nodes itself may be changed.ExampleConsiderationCreate a dummy head...
2019-06-24 19:59:49
122
原创 Leetcode 22. Generate Parentheses [medium] [java]
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:ConsiderationFor length n string, it is the comb...
2019-06-22 20:16:35
153
原创 Leetcode 19. Remove Nth Node From End of List [medium][java]
Given a linked list, remove the n-th node from the end of list and return its head.NoteGiven n will always be valid.ExampleIgnored CaseBoundary ProblemConsiderationWe should first know the l...
2019-06-22 14:55:28
115
原创 Leetcode 38. Count and Say [easy][java]
The count-and-say sequence is the sequence of integers with the first five terms as following:ExampleNoteTo find the patterns for the output string, we need to read the string.The next string i...
2019-06-20 22:25:53
150
原创 Leetcode 35. Search Insert Position [easy][java]
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Ex...
2019-06-20 22:11:16
133
原创 Leetcode 27. Remove Element [easy] [java]
Given an array nums and a value val, 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...
2019-06-17 23:45:41
143
原创 Leetcode 26. Remove Duplicates from Sorted Array [easy][java]
Given a sorted array nums, 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 modifyin...
2019-06-17 23:38:56
110
原创 Leetcode 21. Merge Two Sorted Lists [easy][java]
Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.ExampleNotewe should use a du...
2019-06-17 20:54:43
296
原创 Leetcode 20. Valid Parentheses [easy] [java]
Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by ...
2019-06-17 20:26:34
144
原创 Leetcode 18. 4Sum [medium] [java]
4SumGiven an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum ...
2019-06-16 21:01:46
101
原创 Leetcode 17. Letter Combinations of a Phone Number [medium][java]
Letter Combinations of a Phone NumberGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (jus...
2019-06-16 19:57:21
191
原创 Leetcode 16. 3Sum Closest [medium][java]
3Sum ClosestGiven an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that eac...
2019-06-16 16:20:27
109
原创 Leetcode 15. 3Sum [medium][java]
3SumGiven an array nums of n integers, are there elements a, b, c in nums 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...
2019-06-16 14:26:06
139
原创 Leetcode 14. Longest Common Prefix [easy][java]
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.ExampleSolution 1Time Complex...
2019-06-15 20:44:04
144
原创 leetcode 12. Integer to Roman [medium][java]
Integer to RomanExampleSolutionTime Complexity: O(m), space complexity:O(m), where m is the symbol lengthclass Solution { public String intToRoman(int num) { String[] symbol = {"I"...
2019-06-14 19:55:39
97
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人