04 2019 档案

摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 阅读全文
posted @ 2019-04-11 11:17 MarkLeeBYR 阅读(84) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2019-04-11 11:16 MarkLeeBYR 阅读(93) 评论(0) 推荐(0) 编辑
摘要: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 inde 阅读全文
posted @ 2019-04-11 10:55 MarkLeeBYR 阅读(102) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Example 2: Note: class Soluti 阅读全文
posted @ 2019-04-11 10:53 MarkLeeBYR 阅读(72) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2019-04-11 10:53 MarkLeeBYR 阅读(82) 评论(0) 推荐(0) 编辑
摘要: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 orig 阅读全文
posted @ 2019-04-11 10:52 MarkLeeBYR 阅读(88) 评论(0) 推荐(0) 编辑
摘要: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. E 阅读全文
posted @ 2019-04-09 17:50 MarkLeeBYR 阅读(106) 评论(0) 推荐(0) 编辑
摘要: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 ar 阅读全文
posted @ 2019-04-09 17:49 MarkLeeBYR 阅读(99) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2019-04-09 17:48 MarkLeeBYR 阅读(151) 评论(0) 推荐(0) 编辑
摘要: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 a 阅读全文
posted @ 2019-04-09 17:46 MarkLeeBYR 阅读(126) 评论(0) 推荐(0) 编辑
摘要:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2019-04-09 17:08 MarkLeeBYR 阅读(98) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2019-04-09 17:07 MarkLeeBYR 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". Write a function that takes 阅读全文
posted @ 2019-04-09 17:06 MarkLeeBYR 阅读(79) 评论(0) 推荐(0) 编辑
摘要:Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 和415的解法一样 class Solution { public String a 阅读全文
posted @ 2019-04-09 16:42 MarkLeeBYR 阅读(69) 评论(0) 推荐(0) 编辑
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan 阅读全文
posted @ 2019-04-09 16:42 MarkLeeBYR 阅读(88) 评论(0) 推荐(0) 编辑
摘要:Write a function to find the longest common prefix string amongst an array of strings. class Solution { public String longestCommonPrefix(String[] str 阅读全文
posted @ 2019-04-09 16:39 MarkLeeBYR 阅读(110) 评论(0) 推荐(0) 编辑
摘要:Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the 阅读全文
posted @ 2019-04-09 16:37 MarkLeeBYR 阅读(97) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2019-04-09 16:36 MarkLeeBYR 阅读(108) 评论(0) 推荐(0) 编辑
摘要: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 versi 阅读全文
posted @ 2019-04-09 16:35 MarkLeeBYR 阅读(97) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list, determine if it is a palindrome. public class Solution { public boolean isPalindrome(ListNode head) { ListNode fast = head 阅读全文
posted @ 2019-04-09 16:31 MarkLeeBYR 阅读(89) 评论(0) 推荐(0) 编辑
摘要: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 is 1 -> 2 -> 3 - 阅读全文
posted @ 2019-04-09 16:31 MarkLeeBYR 阅读(127) 评论(0) 推荐(0) 编辑
摘要:ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5 ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val 阅读全文
posted @ 2019-04-09 16:30 MarkLeeBYR 阅读(112) 评论(0) 推荐(0) 编辑
摘要:看剑指offer 阅读全文
posted @ 2019-04-09 16:29 MarkLeeBYR 阅读(75) 评论(0) 推荐(0) 编辑
摘要: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 h 阅读全文
posted @ 2019-04-09 16:28 MarkLeeBYR 阅读(86) 评论(0) 推荐(0) 编辑
摘要: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. public c 阅读全文
posted @ 2019-04-09 16:27 MarkLeeBYR 阅读(171) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2019-04-09 16:27 MarkLeeBYR 阅读(98) 评论(0) 推荐(0) 编辑
摘要:* Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } 阅读全文
posted @ 2019-04-09 16:23 MarkLeeBYR 阅读(106) 评论(0) 推荐(0) 编辑
摘要:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contai 阅读全文
posted @ 2019-04-09 16:22 MarkLeeBYR 阅读(78) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this in on 阅读全文
posted @ 2019-04-09 16:22 MarkLeeBYR 阅读(93) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a 阅读全文
posted @ 2019-04-09 16:21 MarkLeeBYR 阅读(66) 评论(0) 推荐(0) 编辑
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文
posted @ 2019-04-09 16:20 MarkLeeBYR 阅读(68) 评论(0) 推荐(0) 编辑
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. Example: class Solution { public ListNode rotateRight(ListNode head, 阅读全文
posted @ 2019-04-09 16:20 MarkLeeBYR 阅读(123) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. //剑指offer删除链表中重复的结点 Fo 阅读全文
posted @ 2019-04-09 16:19 MarkLeeBYR 阅读(76) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal tox. You should preserve the o 阅读全文
posted @ 2019-04-09 16:19 MarkLeeBYR 阅读(95) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list in O(n log n) time using constant space complexity. //利用归并排序的思想 class Solution { public ListNode sortList(ListNode head) { if (head 阅读全文
posted @ 2019-04-09 16:17 MarkLeeBYR 阅读(102) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list L: 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 阅读全文
posted @ 2019-04-09 16:15 MarkLeeBYR 阅读(84) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list using insertion sort. public class Solution { public ListNode insertionSortList(ListNode head) { ListNode root = new ListNode(0); / 阅读全文
posted @ 2019-04-09 16:15 MarkLeeBYR 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you 阅读全文
posted @ 2019-04-09 16:14 MarkLeeBYR 阅读(84) 评论(0) 推荐(0) 编辑