- 博客(151)
- 资源 (1)
- 收藏
- 关注
转载 209.Minimum Size Subarray Sum
Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 instead. For example, given the array[...
2019-04-11 11:17:00
138
转载 228.Summary Ranges
Input:[0,1,2,4,5,7]Output:["0->2","4->5","7"]Explanation:0,1,2 form a continuous range;4,5 form a continuous range. class Solution { public List<String> summaryRanges(int[] ...
2019-04-11 11:16:00
168
转载 162.Find Peak Element
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple pea...
2019-04-11 10:55:00
110
转载 680. Valid Palindrome II
Given a non-empty strings, you may deleteat mostone character. Judge whether you can make it a palindrome. Example 1: Input:"aba"Output:True Example 2: Input:"abca"Output:TrueExplan...
2019-04-11 10:53:00
93
转载 686. Repeated String Match
Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = "abcd" and B = "cdabcdab"...
2019-04-11 10:53:00
99
转载 657. Judge Route Circle
nitially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back tothe original place. The move sequence is represented...
2019-04-11 10:52:00
121
转载 557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input:"Let's take LeetCode conte...
2019-04-09 17:50:00
91
转载 541. Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of...
2019-04-09 17:49:00
124
转载 520. Detect Capital
Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters i...
2019-04-09 17:48:00
77
转载 459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase ...
2019-04-09 17:46:00
92
转载 383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines...
2019-04-09 17:08:00
99
转载 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Given s = "leetcode", return "leotcede". Note:The ...
2019-04-09 17:07:00
100
转载 344. Reverse String
Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". class Solution { public String reverseString(String s) { ...
2019-04-09 17:06:00
89
转载 67. Add Binary
Given two binary strings, return their sum (also a binary string). For example,a ="11"b ="1"Return"100". 和415的解法一样 class Solution { public String addBinary(String a, String b) { ...
2019-04-09 16:42:00
83
转载 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isnota p...
2019-04-09 16:42:00
83
转载 38. Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1is read off as"one 1"or11.11is read off as"two 1...
2019-04-09 16:41:00
89
转载 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length == 0)...
2019-04-09 16:39:00
93
转载 438.Find All Anagrams in a String
Given a stringsand anon-emptystringp, find all the start indices ofp's anagrams ins. Strings consists of lowercase English letters only and the length of both stringssandpwill not be ...
2019-04-09 16:37:00
83
转载 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 N A P L S I...
2019-04-09 16:36:00
71
转载 165.CompareVersionNumbers
Input:version1= "0.1",version2= "1.1"Output:-1 Input:version1= "7.5.2.4",version2= "7.5.3"Output:-1 public int compareVersion(String version1, String version2) { ...
2019-04-09 16:35:00
149
转载 234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome. public class Solution { public boolean isPalindrome(ListNode head) { ListNode fast = head; ListNode sl...
2019-04-09 16:31:00
58
转载 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. Supposed the linked list is1 -> 2 -> 3 -> 4and you are given the third nod...
2019-04-09 16:31:00
88
转载 203. Remove Linked List Elements
ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --> 4 --> 5 public class Solution {public ListNode removeElements(ListN...
2019-04-09 16:30:00
48
转载 160. Intersection of Two Linked Lists
看剑指offer 转载于:https://www.cnblogs.com/MarkLeeBYR/p/10677814.html
2019-04-09 16:29:00
54
转载 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? public class Solution { public boolean hasCycle(ListNode head) { i...
2019-04-09 16:28:00
60
转载 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce. For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3. ...
2019-04-09 16:27:00
44
转载 21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The newlist should be made by splicing together the nodesof the first two lists. public class Solution { public ListNode merg...
2019-04-09 16:27:00
60
转载 链表的类模型
* Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } 转载于:https://www.cnblogs.com/MarkLeeBYR/p/1067...
2019-04-09 16:23:00
203
转载 19. Remove Nth Node From End of List
Given a linked list, remove thenthnode from the end of list and return its head. For example, Given linked list:1->2->3->4->5, andn= 2. After removing the second node from the ...
2019-04-09 16:22:00
61
转载 2. Add Two Numbers
You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and ret...
2019-04-09 16:22:00
59
转载 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example,Given1->2->3->4, you should return the list as2->1->4->3. Your algorithm should use only ...
2019-04-09 16:21:00
52
转载 92. Reverse Linked List II
Reverse a linked list from positionmton. Do it in-place and in one-pass. For example:Given1->2->3->4->5->NULL,m= 2 andn= 4, return1->4->3->2->5->NULL. No...
2019-04-09 16:20:00
93
转载 61. Rotate List
Given a list, rotate the list to the right bykplaces, wherekis non-negative. Example: Given1->2->3->4->5->NULLandk=2, return4->5->1->2->3->NULL. ...
2019-04-09 16:20:00
56
转载 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list. //剑指offer删除链表中重复的结点 For example,Given1->2->3->3->4-&...
2019-04-09 16:19:00
69
转载 86. Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox. You should preserve the original relative order of the nodes in each ...
2019-04-09 16:19:00
65
转载 148. Sort List
Sort a linked list inO(nlogn) time using constant space complexity. //利用归并排序的思想 class Solution { public ListNode sortList(ListNode head) { if (head == null || head.next == nu...
2019-04-09 16:17:00
62
转载 143. Reorder List
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example,Given{1,2,3,4}, reorder it to{...
2019-04-09 16:15:00
84
转载 147. Insertion Sort List
Sort a linked list using insertion sort. public class Solution { public ListNode insertionSortList(ListNode head) { ListNode root = new ListNode(0); // 头结点 root.next ...
2019-04-09 16:15:00
77
转载 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Note:Do not modify the linked list. Follow up:Can you solve it without using extra space? //之间做...
2019-04-09 16:14:00
56
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人