[LeetCode]Trips and Users
题目描述:LeetCode 262. Trips and UsersThe Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table. Status is an...
View Article[LeetCode]Wiggle Subsequence
题目描述:LeetCode 376. Wiggle SubsequenceA sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first...
View Article[LeetCode]Combination Sum IV
题目描述:LeetCode 377. Combination Sum IVGiven an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums =...
View Article[LeetCode]Kth Smallest Element in a Sorted Matrix
题目描述:LeetCode 378. Kth Smallest Element in a Sorted MatrixGiven a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it...
View Article[LeetCode]Insert Delete GetRandom O(1)
题目描述:LeetCode 380. Insert Delete GetRandom O(1)Design a data structure that supports all following operations in O(1) time.insert(val): Inserts an item val to the set if not already...
View Article[LeetCode]Insert Delete GetRandom O(1) - Duplicates allowed
题目描述:LeetCode 381. Insert Delete GetRandom O(1) - Duplicates allowedDesign a data structure that supports all following operations in averageO(1) time.Note: Duplicate elements are allowed.insert(val):...
View Article[LeetCode]Linked List Random Node
题目描述:LeetCode 382. Linked List Random NodeGiven a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.Follow up: What if the...
View Article[LeetCode]Ransom Note
题目描述:LeetCode 383. Ransom NoteGiven 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...
View Article[LeetCode]Shuffle an Array
题目描述:LeetCode 384. Shuffle an ArrayShuffle a set of numbers without duplicates.Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle...
View Article[LeetCode]Mini Parser
题目描述:LeetCode 385. Mini ParserGiven a nested list of integers represented as a string, implement a parser to deserialize it.Each element is either an integer, or a list -- whose elements may also be...
View Article[LeetCode]Same Tree
题目描述:LeetCode 100. Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the...
View Article[LeetCode]Lexicographical Numbers
题目描述:LeetCode 386. Lexicographical NumbersGiven an integer n, return 1 - n in lexicographical order.For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].Please optimize your algorithm to use...
View Article[LeetCode]First Unique Character in a String
题目描述:LeetCode 387. First Unique Character in a StringGiven a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples: s = "leetcode" return...
View Article[LeetCode]Longest Absolute File Path
题目描述:LeetCode 388. Longest Absolute File PathSuppose we abstract our file system by a string in the following manner:The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2...
View ArticleLeetCode Warm Up Contest解题报告
LeetCode热身赛是LeetCode举办的第一场比赛,共3道题目,比赛时长24小时。比赛链接:https://leetcode.com/contest/detail/1题解列表:LeetCode 386. Lexicographical NumbersLeetCode 387. First Unique Character in a StringLeetCode 388. Longest...
View Article[LeetCode]Find the Difference
题目描述:LeetCode 389. Find the DifferenceGiven two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random...
View Article[LeetCode]Elimination Game
题目描述:LeetCode 390. Elimination GameThere is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the...
View Article[LeetCode]Perfect Rectangle
题目描述:LeetCode 391. Perfect RectangleGiven N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region.Each rectangle is represented as a...
View ArticleLeetCode Weekly Contest 2解题报告
LeetCode Weekly Contest 2是LeetCode举办的第一场正式周赛,共3道题目,比赛时长2.5小时。比赛链接:https://leetcode.com/contest/detail/2题解列表:LeetCode 389. Find the DifferenceLeetCode 390. Elimination GameLeetCode 391. Perfect Rectangle
View Article[LeetCode]Flatten Binary Tree to Linked List
题目描述:LeetCode 114. Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2 \ 3 \ 4...
View Article