上一页 1 2 3 4 5 6 7 ··· 15 下一页
摘要: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: 思路:回溯 阅读全文
posted @ 2019-09-18 17:24 琴影 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Given a collection of distinct integers, return all possible permutations. Example: 思路一:二话不说,经典题, 回溯。 思路二: 阅读全文
posted @ 2019-09-18 16:35 琴影 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2019-09-18 16:02 琴影 阅读(181) 评论(0) 推荐(0) 编辑
摘要: You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be rep 阅读全文
posted @ 2019-09-18 09:10 琴影 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Input: "Hello" Output: "hello" 阅读全文
posted @ 2019-09-17 21:25 琴影 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: 思 阅读全文
posted @ 2019-09-17 21:16 琴影 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given two arrays, write a function to compute their intersection. Example 1: Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Exam 阅读全文
posted @ 2019-09-17 11:00 琴影 阅读(91) 评论(0) 推荐(0) 编辑
摘要: Given two arrays, write a function to compute their intersection. Example 1: Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9] Exam 阅读全文
posted @ 2019-09-17 09:57 琴影 阅读(142) 评论(0) 推荐(0) 编辑
摘要: You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c 阅读全文
posted @ 2019-09-16 23:30 琴影 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime com 阅读全文
posted @ 2019-09-16 23:22 琴影 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Example 2: 阅读全文
posted @ 2019-09-16 22:30 琴影 阅读(233) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: 思路:一次填充矩阵外围一轮数。 阅读全文
posted @ 2019-09-16 17:31 琴影 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. The matching should cover the entire in 阅读全文
posted @ 2019-09-16 16:48 琴影 阅读(286) 评论(0) 推荐(0) 编辑
摘要: Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. The matching should cover the entire  阅读全文
posted @ 2019-09-16 15:58 琴影 阅读(229) 评论(0) 推荐(0) 编辑
摘要: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 阅读全文
posted @ 2019-09-16 09:34 琴影 阅读(259) 评论(0) 推荐(0) 编辑
摘要: Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: A partially filled sudoku which 阅读全文
posted @ 2019-09-15 12:58 琴影 阅读(177) 评论(0) 推荐(0) 编辑
摘要: The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 阅读全文
posted @ 2019-09-14 18:27 琴影 阅读(224) 评论(0) 推荐(0) 编辑
摘要: On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square. There is exactly one starting square. 2 represents the ending 阅读全文
posted @ 2019-09-14 11:04 琴影 阅读(476) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-09-13 23:04 琴影 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Example 2: 思路:d 阅读全文
posted @ 2019-09-13 00:31 琴影 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Given several boxes with different colors represented by different positive numbers. You may experience several rounds to remove boxes until there is 阅读全文
posted @ 2019-09-12 11:36 琴影 阅读(364) 评论(0) 推荐(0) 编辑
摘要: Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon 阅读全文
posted @ 2019-09-09 17:44 琴影 阅读(189) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in 阅读全文
posted @ 2019-09-09 11:37 琴影 阅读(257) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2019-09-09 10:38 琴影 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目描述 给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4] 阅读全文
posted @ 2019-09-08 13:07 琴影 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 题目描述 给你一根长度为n的绳子,请把绳子剪成m段(m、n都是整数,n>1并且m>1),每段绳子的长度记为k[0],k[1],...,k[m]。请问k[0]xk[1]x...xk[m]可能的最大乘积是多少?例如,当绳子的长度是8时,我们把它剪成长度分别为2、3、3的三段,此时得到的最大乘积是18。 阅读全文
posted @ 2019-09-06 17:06 琴影 阅读(443) 评论(0) 推荐(0) 编辑
摘要: 题目描述 请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。 输出描述: 如果当前字符流没有存在出现一次的字符,返回#字符。 请实现一个函 阅读全文
posted @ 2019-09-06 15:07 琴影 阅读(301) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Example 2: Note: Length of the given array will be 阅读全文
posted @ 2019-09-05 19:23 琴影 阅读(275) 评论(0) 推荐(0) 编辑
摘要: Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文
posted @ 2019-09-05 16:57 琴影 阅读(357) 评论(0) 推荐(0) 编辑
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are ar 阅读全文
posted @ 2019-09-05 16:46 琴影 阅读(173) 评论(0) 推荐(0) 编辑
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2019-09-05 16:14 琴影 阅读(241) 评论(0) 推荐(0) 编辑
摘要: Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文
posted @ 2019-09-05 15:06 琴影 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 题目描述 对于输入的字符串,从左到右扫描字符串,如果存在由三个以上(包括三个)连续相同字符组成的子串,就将这个子串从原串中去掉,并将原有字符串剩下的部分拼接到一起。重复上述过程,直到无法去掉任何子串 输入描述: 输入的字符串 输出描述: 最后剩下的子串 示例1 输入 AAABCCDDDCB 输出 B 阅读全文
posted @ 2019-09-04 17:46 琴影 阅读(1390) 评论(0) 推荐(0) 编辑
摘要: Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2019-09-04 16:51 琴影 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 时间限制:1秒 空间限制:262144K 时间限制:1秒 空间限制:262144K 给定两个-100到100的整数x和y,对x只能进行加1,减1,乘2操作,问最少对x进行几次操作能得到y? 例如:a=3,b=11: 可以通过3*2*2-1,3次操作得到11;a=5,b=8:可以通过(5-1)*2,2 阅读全文
posted @ 2019-09-04 09:21 琴影 阅读(1137) 评论(0) 推荐(1) 编辑
摘要: 题目描述 在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写). 在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区 阅读全文
posted @ 2019-09-04 09:08 琴影 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe 阅读全文
posted @ 2019-09-03 23:08 琴影 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 时间限制:1秒 空间限制:65536K 时间限制:1秒 空间限制:65536K 在你面前有一个n阶的楼梯,你一步只能上1阶或2阶。请问计算出你可以采用多少种不同的方式爬完这个楼梯。 输入描述: 一个正整数n(n<=100),表示这个楼梯一共有多少阶 输出描述: 一个正整数,表示有多少种不同的方式爬完 阅读全文
posted @ 2019-08-31 22:50 琴影 阅读(847) 评论(0) 推荐(0) 编辑
摘要: 加法:(字符串模拟小学加法) 减法: 乘法: 除法: 取模: 1)(a * b) % m = (a % m * b % m) % m = (a % m * b) % m = (a * b % m) % m 2) (a + b) % m = (a % m + b % m) % m = (a % m + 阅读全文
posted @ 2019-08-31 22:47 琴影 阅读(3519) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, it 阅读全文
posted @ 2019-08-30 23:32 琴影 阅读(787) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 15 下一页