
LeetCode
zhangjun62
我是一个爱学习、爱动漫的程序员
展开
-
LeetCode146 LRU Cache
题目: Design and implement a data structure forLeast Recently Used (LRU) cache. It should support the following operations:getandput. get(key)- Get the value (will always be positiv...原创 2019-08-16 21:38:21 · 179 阅读 · 0 评论 -
LeetCode15 3Sum
题目: Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero. Note: The ...原创 2019-07-23 15:21:10 · 125 阅读 · 0 评论 -
LeetCode149 Max Points on a Line
题目: Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Input: [[1,1],[2,2],[3,3]] Output: 3 Explana...原创 2019-07-23 09:44:44 · 243 阅读 · 0 评论 -
LeetCode447 Number of Boomerangs
题目: Givennpoints in the plane that are all pairwise distinct, a "boomerang" is a tuple of points(i, j, k)such that the distance betweeniandjequals the distance betweeniandk(the orde...原创 2019-07-23 09:23:47 · 179 阅读 · 0 评论 -
LeetCode454 4Sum II
题目: Given four lists A, B, C, D of integer values, compute how many tuples(i, j, k, l)there are such thatA[i] + B[j] + C[k] + D[l]is zero. To make problem a bit easier, all A, B, C...原创 2019-07-23 09:17:56 · 115 阅读 · 0 评论 -
LeetCode219 Contains Duplicate II
题目: Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and theabsolutedifference betweeniandjis ...原创 2019-07-23 09:07:58 · 134 阅读 · 0 评论 -
LeetCode220 Contains Duplicate III
题目: Given an array of integers, find out whether there are two distinct indicesiandjin the array such that theabsolutedifference betweennums[i]andnums[j]is at mosttand theabsolute...原创 2019-07-23 08:58:25 · 139 阅读 · 0 评论 -
LeetCode1 Two Sum
题目: Given an array of integers, returnindicesof the two numbers such that they add up to a specific target. You may assume that each input would haveexactlyone solution, and you ma...原创 2019-07-20 21:39:16 · 106 阅读 · 0 评论 -
LeetCode451 Sort Characters By Frequency
题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: ...原创 2019-07-20 14:12:39 · 140 阅读 · 0 评论 -
leetCode290 Word Pattern
题目: Given apatternand a stringstr, find ifstrfollows the same pattern. Herefollowmeans a full match, such that there is a bijection between a letter inpatternand anon-emptyw...原创 2019-07-17 13:08:56 · 161 阅读 · 0 评论 -
LeetCode49 Group Anagrams
题目: Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ...原创 2019-07-28 23:29:58 · 142 阅读 · 0 评论 -
LeetCode205 Isomorphic Strings
题目: Given two stringssandt, determine if they are isomorphic. Two strings are isomorphic if the characters inscan be replaced to gett. All occurrences of a character must...原创 2019-07-19 09:00:08 · 120 阅读 · 0 评论 -
LeetCode16 3Sum Closest
题目: Given an arraynumsofnintegers and an integertarget, find three integers innumssuch that the sum is closest totarget. Return the sum of the three integers. You may assume that each ...原创 2019-07-27 23:43:40 · 161 阅读 · 0 评论 -
LeetCode92 Reverse Linked List II
题目: Reverse a linked list from positionmton. Do it in one-pass. Note:1 ≤m≤n≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4...原创 2019-08-06 14:02:48 · 137 阅读 · 0 评论 -
LeetCode233 Number of Digit One
题目: Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. Example: Input: 13 Output: 6 Explanati...原创 2019-08-16 10:22:34 · 185 阅读 · 0 评论 -
LeetCode86 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 ...原创 2019-08-07 16:04:19 · 245 阅读 · 0 评论 -
LeetCode83 Remove Duplicates from Sorted List
题目: Given a sorted linked list, delete all duplicates such that each element appear onlyonce. Example 1: Input: 1->1->2 Output: 1->2 Example 2: ...原创 2019-08-07 13:59:14 · 243 阅读 · 0 评论 -
LeetCode25 Reverse Nodes in k-Group
题目: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list. kis a positive integer and is less than or equal to the length of the linked list...原创 2019-08-13 21:51:02 · 221 阅读 · 0 评论 -
LeetCode24 Swap Nodes in Pairs
题目: Given alinked list, swap every two adjacent nodes and return its head. You maynotmodify the values in the list's nodes, only nodes itself may be changed. Example: ...原创 2019-08-13 17:08:34 · 188 阅读 · 0 评论 -
LeetCode21 Merge Two Sorted Lists
题目: 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,...原创 2019-08-13 17:04:05 · 181 阅读 · 0 评论 -
LeetCode82 Remove Duplicates from Sorted List II
题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list. Example 1: Input: 1->2->3->3->4-...原创 2019-08-13 16:40:14 · 256 阅读 · 0 评论 -
LeetCode203
题目: Remove all elements from a linked list of integers that have valueval. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4-&...原创 2019-08-13 15:51:56 · 158 阅读 · 0 评论 -
LeetCode445 Add Two Numbers II
题目: You are given twonon-emptylinked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers ...原创 2019-08-13 15:43:29 · 218 阅读 · 0 评论 -
LeetCode2 Add Two Numbers
题目: You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse orderand each of their nodes contain a single digit. Add the two numbers ...原创 2019-08-13 14:19:57 · 259 阅读 · 0 评论 -
LeetCode328 Odd Even Linked List
题目: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You shoul...原创 2019-08-13 14:00:28 · 167 阅读 · 0 评论 -
LeetCode202 Happy Number
题目: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the s...原创 2019-07-12 14:38:28 · 177 阅读 · 0 评论 -
LeetCode206 Reverse Linked List
题目: Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list...原创 2019-07-23 16:41:01 · 141 阅读 · 0 评论 -
LeetCode18 4Sum
题目: Given an arraynumsofnintegers and an integertarget, are there elementsa,b,c, anddinnumssuch thata+b+c+d=target? Find all unique quadruplets in the array which gives th...原创 2019-07-23 15:55:04 · 141 阅读 · 0 评论 -
LeetCode26 Remove Duplicates from Sorted Array
题目: 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 ...原创 2019-05-28 08:49:58 · 132 阅读 · 0 评论 -
LeetCode27 Remove Element
题目: 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 modif...原创 2019-05-27 20:50:14 · 109 阅读 · 0 评论 -
LeetCode747 Largest Number At Least Twice of Others
题目: In a given integer array nums, there is always exactly one largest element.Find whether the largest element in the array is at least twice as much as every other number in the array.If it ...原创 2019-05-27 16:45:53 · 130 阅读 · 0 评论 -
LeetCode728 Self Dividing Numbers
题目: A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0....原创 2019-05-27 15:32:46 · 112 阅读 · 0 评论 -
LeetCode163 Missing Ranges
题目: Given a sorted integer array where the range of elements are in the inclusive range {lower, upper}, return its missing ranges For examplegiven{0, 1, 3, 50, 75}, lower =0 and uppe...原创 2019-05-21 09:37:30 · 161 阅读 · 0 评论 -
LeetCode369 Plus One Linked List
题目: Given a NON-NEGATIVE integer represented as non-empty a singly linked list of digits, plus one to the integer. You may assume the integer do not contain any leading zero, except the number...原创 2019-05-22 12:54:12 · 142 阅读 · 0 评论 -
LeetCode704 Binary Search
题目: Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise retur...原创 2019-05-25 15:07:02 · 107 阅读 · 0 评论 -
LeetCode34 Find First and Last Position of Element in Sorted Array
题目: 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...原创 2019-05-25 16:05:18 · 122 阅读 · 0 评论 -
LeetCode374 Guess Number Higher or Lower
题目: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the nu...原创 2019-05-25 16:31:56 · 134 阅读 · 0 评论 -
LeetCode69 Sqrt(x)
题目: Implement int sqrt(int x). Compute and return the square root of x, wherexis guaranteed to be a non-negative integer. Since the return typeis an integer, the decimal dig...原创 2019-05-25 16:57:42 · 160 阅读 · 0 评论 -
LeetCode283 Move Zeroes
题目: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12]...原创 2019-05-25 22:48:09 · 94 阅读 · 0 评论 -
LeetCode80 Remove Duplicates from Sorted Array II
题目: Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at mosttwice and return the new length. Do not allocate extra space for another array, you ...原创 2019-05-28 09:55:59 · 131 阅读 · 0 评论