LintCode --- k数和II

Given n unique integers, number k (1<=k<=n) and target. Find all possible k integers where their sum is target. 样例 给出[1,2,3,...

2018-07-10 22:29:37

阅读数:25

评论数:0

三个整数

#include <iostream> #include <vector> #include <string> #include <al...

2018-04-19 21:05:45

阅读数:33

评论数:0

2018阿里测试

有个穷困的艺术家。他画了一幅超现实主义的作品《方块手拉手》。现在他已经把图画中手拉手的一排大小不一的方块都画出来了。现在要考虑上颜色了。可惜他手中的钱并不多了。但是他是个有追求的人,他希望这幅画中每两个相邻的方块的颜色是不一样的。你能帮他计算一下把这幅画上色后,最少需要花多少钱么。 输入: 第...

2018-03-15 19:31:49

阅读数:839

评论数:1

剑指offer--机器人的运动范围

题目描述 地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为...

2018-03-12 20:07:24

阅读数:34

评论数:0

剑指offer---矩阵中的路径

题目描述 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。 例如 a b c e s f c s a d e e ...

2018-03-12 13:32:45

阅读数:43

评论数:0

剑指offer---字符串的排列

输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 输入描述: 输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。 class Solution...

2018-03-06 19:39:10

阅读数:34

评论数:0

剑指offer---二叉树中和为某一值的路径

输入一颗二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。 /* struct TreeNode { int val; struct TreeNode *left; struct TreeN...

2018-03-06 08:39:41

阅读数:32

评论数:0

leetcode---valid-sudoku--dfs

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled ...

2018-02-27 23:59:51

阅读数:20

评论数:0

leetcode---sudoku-solver

Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character’.’. You may assume that there wil...

2018-02-27 22:12:43

阅读数:34

评论数:0

leetcode---subsets---回溯

Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set ...

2018-02-23 16:52:47

阅读数:38

评论数:0

leetcode---letter-combinations-of-a-phone-number---dfs

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telep...

2018-01-21 21:08:26

阅读数:65

评论数:0

leetcode---n-queens---dfs

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return al...

2018-01-21 20:37:34

阅读数:57

评论数:0

leetcode---palindrome-partitioning---dp, dfs

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exa...

2017-11-13 18:07:19

阅读数:85

评论数:0

leetcode---generate-parentheses---dfs

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:...

2017-10-03 18:20:20

阅读数:147

评论数:0

leetcode---combination-sum---dfs

Given a set of candidate numbers ( C ) and a target number ( T ), find all unique combinations in C where the candidate numbers sums to T . The same...

2017-10-01 16:22:21

阅读数:85

评论数:0

leetcode---word-search---dfs

Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adj...

2017-09-29 20:05:26

阅读数:112

评论数:0

leetcode---combinations---dfs

Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and k = 2, a solution is: [ [2,4]...

2017-09-29 19:18:00

阅读数:93

评论数:0

leetcode---permutations-ii---dfs

Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2]have the following unique...

2017-09-22 12:14:43

阅读数:65

评论数:0

leetcode---permutations---dfs

Given a collection of numbers, return all possible permutations. For example, [1,2,3]have the following permutations: [1,2,3],[1,3,2],[2,1,3],[2,3...

2017-09-22 12:02:27

阅读数:83

评论数:0

leetcode---Reconstruct Itinerary---dfs

Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tic...

2017-04-09 19:36:15

阅读数:403

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭