随笔分类 - LeetCode
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->
阅读全文
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo
阅读全文
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECO
阅读全文
摘要:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j]
阅读全文
摘要:Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] an
阅读全文
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr
阅读全文
摘要:Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element.
阅读全文
摘要:Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a functi
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va
阅读全文
摘要:Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 要求不使用乘法、除法或模运算实现: dividend/divisor,也就是
阅读全文
摘要:Implement pow(x, n).
阅读全文
摘要:Implement int sqrt(int x). Compute and return the square root of x.
阅读全文
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of
阅读全文
摘要: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 the two n
阅读全文
摘要:Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to
阅读全文
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return
阅读全文
摘要:Invert a binary tree. to Trivia: This problem was inspired by this original tweet by Max Howell:
阅读全文
摘要:Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is a
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings.
阅读全文