
LeetCode
小哥哥咯
爱自由,爱生活!
展开
-
LeetCode刷题day044 (Jieky)
**LeetCode第10题 Regular Expression Matching **/*Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*''.' Matches any single character.'*' Matches zero or more of the preceding element.The matc原创 2021-04-25 23:26:45 · 183 阅读 · 0 评论 -
LeetCode刷题day043 (Jieky)
LeetCode第43题 Multiply Strings/*Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Note: You must not use any built-in BigInteger library or convert the inputs to integ原创 2021-04-24 20:13:15 · 107 阅读 · 0 评论 -
LeetCode刷题day042 (Jieky)
LeetCode第42题 Trapping Rain Water/*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.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1原创 2021-04-22 23:27:20 · 136 阅读 · 0 评论 -
LeetCode刷题day041 (Jieky)
LeetCode第41题 First Missing Positive/*Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0] Output: 3 Example 2:Input: [3,4,-1,1] Output: 2 Example 3:Input: [7,8,9,11,12] Output: 1 Note:Y原创 2021-04-12 11:30:23 · 128 阅读 · 0 评论 -
LeetCode刷题day040 (Jieky)
LeetCode第39题 Combination Sum II/*Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.Each number in candidates may only be used once in原创 2021-04-12 10:04:15 · 133 阅读 · 0 评论 -
LeetCode刷题day039 (Jieky)
LeetCode第39题 Combination Sum/*Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repeated number may be chosen原创 2021-04-09 21:32:47 · 142 阅读 · 0 评论 -
LeetCode刷题day038 (Jieky)
LeetCode第38题 Count and Say/*The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1"or 11.11 is read off as "two 1s"or 2121 is read off as "one 2, then原创 2021-03-27 10:21:31 · 131 阅读 · 0 评论 -
LeetCode刷题day037 (Jieky)
LeetCode第36题 Sudoku Solver/*Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules: 1.Each of the digits 1-9 must occur exactly once in each row. 2.Each of the digits 1-9 must occ原创 2021-03-20 10:11:39 · 103 阅读 · 0 评论 -
LeetCode刷题day036 (Jieky)
LeetCode第36题 Valid Sudoku/*Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each column must contain the digits 1-9 without re原创 2021-03-19 22:31:27 · 148 阅读 · 0 评论 -
LeetCode刷题day035 (Jieky)
LeetCode第35题 Search Insert Position/*题目 #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.Example 1:In原创 2021-03-19 21:22:00 · 130 阅读 · 0 评论 -
LeetCode刷题day034 (Jieky)
LeetCode第34题 Find First and Last Position of Element in Sorted Array/*Given an array of integers mums 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原创 2021-02-24 21:30:01 · 118 阅读 · 0 评论 -
LeetCode刷题day033 (Jieky)
LeetCode第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原创 2021-02-23 22:52:33 · 165 阅读 · 0 评论 -
LeetCode刷题day032 (Jieky)
LeetCode第32题 Longest Valid Parentheses/*Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring Example 1: Input: "(()"Output: 2Explanation: The longest valid parentheses sub原创 2021-02-22 23:56:03 · 195 阅读 · 1 评论 -
LeetCode刷题day031 (Jieky)
LeetCode第30题 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 order (ie, sorted in asc原创 2021-02-10 22:41:16 · 151 阅读 · 0 评论 -
LeetCode刷题day030 (Jieky)
LeetCode第30题/*You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.Examp原创 2021-02-06 11:53:20 · 201 阅读 · 0 评论 -
LeetCode刷题day029 (Jieky)
LeetCode第29题/*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 should truncate toward zero.Example 1:Inpu原创 2021-02-04 00:13:48 · 225 阅读 · 2 评论 -
LeetCode刷题day028 (Jieky)
LeetCode第28题/*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: 2Example 2:Input: haystack = "aaaaa", needle = "bba原创 2021-02-02 23:25:11 · 188 阅读 · 2 评论 -
LeetCode刷题day027 (Jieky)
LeetCode第27题/*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 in-place with O(1) extra memory.The or原创 2021-02-01 23:43:45 · 136 阅读 · 1 评论 -
LeetCode刷题day026 (Jieky)
LeetCode第26题/*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 modifying the input array in-place with O(1) ext原创 2021-01-29 21:56:27 · 173 阅读 · 2 评论 -
LeetCode刷题day025 (Jieky)
LeetCode第25题/*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 nodes is not a multiple of k then left-o原创 2021-01-28 21:57:52 · 155 阅读 · 3 评论 -
LeetCode刷题day024 (Jieky)
LeetCode第24题class ListNode{ int val; ListNode next; ListNode(){}; ListNode(int val){this.val=val;} ListNode(int val, ListNode next) { this.val = val; this.next = next; }}public class SwapNodesPairs{ public static void main(String[] args){ ListN原创 2021-01-18 23:30:14 · 107 阅读 · 0 评论 -
LeetCode刷题day023 (Jieky)
LeetCode第23题/*Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4->4->5->6*/import java.util.*;原创 2021-01-09 18:33:24 · 204 阅读 · 4 评论 -
LeetCode刷题day022 (Jieky)
LeetCode第22题/*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:[ "((()))", "(()())", "(())()", "()(())", "()()()"]*/import java.util.*;cla原创 2021-01-07 23:25:44 · 145 阅读 · 0 评论 -
LeetCode刷题day021 (Jieky)
LeetCode第21题/*Merge 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.Example:Input: 1->2->4, 1->3->4Output: 1->1->2->3->4->4*/class Lis原创 2021-01-06 22:40:46 · 105 阅读 · 1 评论 -
LeetCode刷题day020 (Jieky)
LeetCode第20题/*Given 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 the same type of brackets. Open brackets must be closed in原创 2021-01-05 22:37:08 · 139 阅读 · 1 评论 -
LeetCode刷题day019 (Jieky)
LeetCode第19题/*Remove Nth Node From End of List #题目 #Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the原创 2020-12-29 23:05:56 · 132 阅读 · 0 评论 -
LeetCode刷题day018 (Jieky)
LeetCode第18题/*Given 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 of target.Note:The solution set must not co原创 2020-12-28 23:41:45 · 122 阅读 · 0 评论 -
LeetCode刷题day017 (Jieky)
LeetCode第17题/*Given a string containing digits from 2-9 inclusive, 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. Note that 1 does not map to an原创 2020-12-27 21:56:26 · 250 阅读 · 2 评论 -
LeetCode刷题day016 (Jieky)
LeetCode第16题/*Given 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 each input would have exactly one solution.Example:Giv原创 2020-12-24 23:56:48 · 135 阅读 · 0 评论 -
LeetCode刷题day015 (Jieky)
LeetCode第15题/*Given 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 contain duplicate triplets.Example:Given a原创 2020-12-23 23:47:25 · 168 阅读 · 1 评论 -
LeetCode刷题day014 (Jieky)
LeetCode第13题/*Roman numerals are represented by seven different symbols: I(1), V(5), X(10), L(50), C(100), D(500) and M(1000).For example, two is written as II in Roman numeral, just two one's added together. Twelve is writen as, XII , which is simply原创 2020-12-22 21:32:55 · 135 阅读 · 1 评论 -
LeetCode刷题day013 (Jieky)
LeetCode第14题/*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: "f1"Example 2: Input: ["dog", "racecar"原创 2020-12-21 23:28:45 · 179 阅读 · 1 评论 -
LeetCode刷题day012 (Jieky)
LeetCode第12题/*Roman numerals are represented by seven different symbols: I(1), V(5), X(10), L(50), C(100), D(500) and M(1000).For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII which is simply X原创 2020-12-20 22:12:45 · 237 阅读 · 4 评论 -
LeetCode刷题day011 (Jieky)
LeetCode第11题/*Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a原创 2020-12-19 20:11:18 · 234 阅读 · 1 评论 -
LeetCode刷题day010 (Jieky)
LeetCode第9题/*Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExplanation: From left to right, it reads -121. Fr原创 2020-12-18 22:25:49 · 151 阅读 · 1 评论 -
LeetCode刷题day009 (Jieky)
LeetCode第8题/*Given an input string (s) and a pattern (p). 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 inp原创 2020-12-17 23:48:58 · 120 阅读 · 0 评论 -
LeetCode刷题day008 (Jieky)
LeetCode第8题/*Implement atoi which converts a string to an integer The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial pl原创 2020-12-16 23:39:50 · 118 阅读 · 0 评论 -
LeetCode刷题day007 (Jieky)
LeetCode第7题/*Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note: Assume we are dealing with an environment which could only store in原创 2020-12-15 23:18:17 · 141 阅读 · 0 评论 -
LeetCode刷题day006 (Jieky)
LeetCode第6题/*将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下:L C I RE T O E S I I GE D H N之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"LCIRETOESIIGEDHN"。请你实现这个将字符串进行指定行数变换的函数:string convert(string s, int numRows);原创 2020-12-14 22:41:18 · 136 阅读 · 0 评论 -
LeetCode刷题day005 (Jieky)
上一篇博客问题解/*最长上升子序列(LIS)问题:给定长度为n的序列a,从a中抽取出一个子序列,这个子序列需要单调递增。问最长的上升子序列(LIS)的长度。 e.g. 1,5,3,4,6,9,7,8的LIS为1,3,4,6,7,8,长度为6。*/import java.util.Arrays;public class Test02 { public static void main(String[] args){ // 最坏情况,数列是降序的,最长升序子序列长度为1原创 2020-12-13 23:56:09 · 192 阅读 · 0 评论