随笔分类 - leetcode
摘要:Question Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “
阅读全文
摘要:2018 8 6 1. Lowest Common Ancestor of a Binary Tree(二叉树) 2. Merge Intervals(排序) 2018 8 7 1. Maximal Square (动态规划) 2018 8 8 剑指offer 1~20 1. 二维数组中的查找 2.
阅读全文
摘要:Question You are given a list of non negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and . For each integer, you should
阅读全文
摘要:Question Given a non empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of element
阅读全文
摘要:1. Question Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3],
阅读全文
摘要:1. Question Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement i
阅读全文
摘要:1. Question Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runt
阅读全文
摘要:1. Question You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in
阅读全文
摘要:Question There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time comp
阅读全文
摘要:1. Question Given n pairs of parentheses, write a function to generate all combinations of well formed parentheses. For example, given n = 3, a soluti
阅读全文
摘要:1. Question Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in th
阅读全文
摘要:1. Question 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
阅读全文
摘要:1. Question Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k tim
阅读全文
摘要:1. Question Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000. Example 1:
阅读全文
摘要:1. Question Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the gi
阅读全文
摘要:Question Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Solution 1. 归并排序中的Merge过程。 2. 时间复杂度: 节点数目
阅读全文
摘要:Question Given a list, rotate the list to the right by k places, where k is non negative. For example: Given1 2 3 4 5 NULLand k =2, return4 5 1 2 3 NU
阅读全文
摘要:Question Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represents y
阅读全文
摘要:Question Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represents y
阅读全文
摘要:Question Given a m x n grid filled with non negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along i
阅读全文