随笔分类 - leetcode
摘要:Question 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.
阅读全文
摘要:Question Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run time complexity? How and why? Write
阅读全文
摘要:Question Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given1 1 2, return1 2. Given1 1 2 3 3
阅读全文
摘要:Question Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,
阅读全文
摘要:Question Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. Solution 这个题目可以借鉴 "Leet
阅读全文
摘要:Question Given n non negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in
阅读全文
摘要:Question Given a non empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time
阅读全文
摘要:Question 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
阅读全文
摘要:Question Sort a linked list in O(n log n) time using constant space complexity. Solution 分析,时间复杂度要求为nlogn,因此得考虑归并排序,但是空间必须为常量,因此得注意指针的操作。 Code
阅读全文
摘要:Question Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Return
阅读全文
摘要:Question Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run time complexity? How and why?
阅读全文
摘要:Question Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j]
阅读全文
摘要:Question Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either
阅读全文
摘要:Question You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins tha
阅读全文
摘要:Question Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of
阅读全文
摘要:Question Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)
阅读全文
摘要:Question Given n non negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in
阅读全文
摘要:Question Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brac
阅读全文
摘要:Question Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of
阅读全文
摘要:Question Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n is positive and will fit within the range
阅读全文