LeetCode
杨缘一
不断接近,终将到达
展开
-
3.Longest Substring Without Repeating Characters
题目描述:Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “b”,原创 2017-12-08 22:03:28 · 186 阅读 · 0 评论 -
209. Minimum Size Subarray Sum
题目Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.For example, given the arra原创 2017-12-16 13:41:35 · 239 阅读 · 2 评论 -
229. Majority Element II
题目描述Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.思路分析对于上一题,数组中个数超过n/2的数值如果存在,则仅有一个。 数组中个数超过n/3的数值可原创 2017-12-15 13:10:31 · 202 阅读 · 0 评论 -
169. Majority Element
题目描述Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alw原创 2017-12-15 10:29:30 · 176 阅读 · 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原创 2017-12-12 10:28:39 · 179 阅读 · 0 评论 -
454. 4Sum Ⅱ
题目描述Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same leng原创 2017-12-12 10:51:43 · 309 阅读 · 0 评论 -
76. Minimum Window Substring
题目描述Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example, S = “ADOBECODEBANC” T = “ABC” Minimum window is “BANC”.No原创 2017-12-19 19:15:00 · 198 阅读 · 0 评论 -
159. Longest Substring with At Most Two Distinct Characters
题目描述Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example, Given s = “eceba”, T is “ece” which its length is 3.思路分析这题依旧是滑动窗口的思想 要求找到最长的只原创 2017-12-19 22:42:38 · 284 阅读 · 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 exac原创 2017-12-11 12:09:49 · 182 阅读 · 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原创 2017-12-11 11:47:38 · 253 阅读 · 0 评论 -
1.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 sa原创 2017-12-11 11:21:54 · 149 阅读 · 0 评论 -
字符串操作的题目
1、按长度为8拆分每个字符串后输出到新的字符串数组; 长度不是8整数倍的字符串请在后面补数字0,空字符串不处理。 public static void cutString(String str) { if(str == null || str.length()<=0) { return; } ...原创 2018-03-23 16:02:02 · 387 阅读 · 0 评论