随笔分类 -  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: “ 阅读全文
posted @ 2018-08-06 13:02 清水汪汪 阅读(153) 评论(0) 推荐(0) 编辑
摘要: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. 阅读全文
posted @ 2018-08-06 12:54 清水汪汪 阅读(283) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2018-07-26 09:44 清水汪汪 阅读(613) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2018-07-26 08:13 清水汪汪 阅读(212) 评论(0) 推荐(0) 编辑
摘要:1. Question Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], 阅读全文
posted @ 2017-11-12 21:13 清水汪汪 阅读(117) 评论(0) 推荐(0) 编辑
摘要:1. Question Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement i 阅读全文
posted @ 2017-11-12 20:32 清水汪汪 阅读(146) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-11 21:48 清水汪汪 阅读(115) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-11 12:04 清水汪汪 阅读(161) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-10 11:20 清水汪汪 阅读(145) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-07 11:50 清水汪汪 阅读(127) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-07 11:09 清水汪汪 阅读(87) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-07 10:21 清水汪汪 阅读(117) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-05 11:43 清水汪汪 阅读(198) 评论(0) 推荐(0) 编辑
摘要: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: 阅读全文
posted @ 2017-11-05 09:38 清水汪汪 阅读(159) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-05 08:57 清水汪汪 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Question Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Solution 1. 归并排序中的Merge过程。 2. 时间复杂度: 节点数目 阅读全文
posted @ 2017-11-01 15:21 清水汪汪 阅读(116) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-11-01 14:24 清水汪汪 阅读(122) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-10-31 22:57 清水汪汪 阅读(174) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-10-31 18:02 清水汪汪 阅读(115) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-10-31 15:41 清水汪汪 阅读(146) 评论(0) 推荐(0) 编辑