题目: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae"…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:电话号码, 字母组合,回溯法,题解,leetcode, 力扣,Python, C++, Java 目录 题目描述 题目大意 解题方法 回溯法 内置函数 循环 日期 题目地址:https://leetcode.com/problems/generate-parentheses/description/ 题目描述 Given a string contain…
题目: 思路:设置两个List,一个存储当前层,一个存储最终层 public class Solution { public List<String> letterCombinations(String digits) { List<String> listRet=new ArrayList<String>(); if(digits==""){ return listRet; } Map<Character,String> map=new…
一天一道LeetCode (一)题目 Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad",…
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetbook/ 017. Letter Combinations of a Phone Number[M] 问题 Given a digit string, return all possible letter combinations that the number could r…
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numberhttps://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/ Given a digit string, return all possible letter combinations that the numbe…
Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. 解题思路: 思路一: 使用DFS算法,JAVA实现如下: static String[] alpha = new String[] { " &q…
Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae", &q…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯 日期 题目地址:https://leetcode.com/problems/letter-tile-possibilities/ 题目描述 You have a set of tiles, where each tile has one letter tiles[i] printed on it. Return the number of pos…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 循环 日期 题目地址:https://leetcode.com/problems/letter-case-permutation/description/ 题目描述 Given a string S, we can transform every letter individually to be lowercase or uppercase…
题目如下: You have a set of tiles, where each tile has one letter tiles[i]printed on it.  Return the number of possible non-empty sequences of letters you can make. Example 1: Input: "AAB" Output: 8 Explanation: The possible sequences are "A&qu…
public List<String> letterCombinations(String digits) { LinkedList<String> ans = new LinkedList<String>(); if(digits == null || digits.length() == 0) return ans; String[] mapping = new String[] {"0", "1", "abc&qu…
给定一个数字字符串,返回数字所有可能表示的字母组合. 输入:数字字符串 "23"输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. 详见:https://leetcode.com/problems/letter-combinations-of-…
1. 原题链接 https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/ 2. 题目要求 给定一个数字字符串digits,每一个数字对应拨号键盘上的数字,每个数字又对应不同的字母.例如“3”对应“d“.“e”.“f”三个字母.输出digits所含数字对应的所有字母组合. 例如,digits="23",输出:["ad", "ae", "…
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Outpu…
[Leetcode]17. 电话号码的字母组合(Letter Combinations of a Phone Number) 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合. 给出数字到字母的映射如下(与电话按键相同).注意 1 不对应任何字母. 示例: 输入:"23"输出:["ad", "ae", "af", "bd", "be", "bf&qu…
[3]Longest Substring Without Repeating Characters (2019年1月22日,复习) [5]Longest Palindromic Substring (2019年1月22日,复习) [6]ZigZag Conversion (2019年1月22日,复习) [8]String to Integer (atoi) (2019年1月22日,复习) [10]Regular Expression Matching (2019年1月22日,复习) [12]In…
[10]Regular Expression Matching [17]Letter Combinations of a Phone Number [22]Generate Parentheses (2019年2月13日) 给了一个N,生成N对括号的所有情况的字符串. n = 3 [ "((()))", "(()())", "(())()", "()(())", "()()()" ] 题解:dfs生成. c…
[3]Longest Substring Without Repeating Characters [11]Container With Most Water [15]3Sum (2019年2月26日) 给了一个乱序的数组,返回一个结果数组,数组里面每个元素是一个三元组, 三元组的和加起来为0. 题解:先固定第一个数,然后后面两个数的控制用夹逼定理,2 pointers 来解. class Solution { public: vector<vector<int>> threeSu…
题目如下: We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. For example, if we have an array A = ["abcdef&quo…
[LeetCode]518. Coin Change 2 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/coin-change-2/description/ 题目描述: You are given coins of different denominations and a total amount of money. Write a…
[LeetCode]880. Decoded String at Index 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/decoded-string-at-index/description/ 题目描述: An encoded string S is given. To find and wri…
[LeetCode]848. Shifting Letters 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/shifting-letters/description/ 题目描述: We have a string S of lowercase letters, and an integer arr…
[LeetCode]831. Masking Personal Information 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/masking-personal-information/description/ 题目描述: We are given a personal information…
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 递归和非递归,此提比较简单.广度优先遍历即可.关键之处就在于如何保持访问深度. 下面是4种代码: im…
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 use only O(k) extra space? 思路:最简单的方法就是依照[Leetcode]Pascal's Triangle 的方式自顶向下依次求解,但会造成空间的浪费.若仅仅用一个vect…
53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] has the largest sum = 6. 挑…
27. Remove Element[leetcode] Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. The order of elements can b…
[刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位数字.在这样做的时候,我们可以预先检查向原整数附加另一位数字是否会导致溢出. 算法: 反转整数的方法可以与反转字符串进行类比. 我们想重复"弹出" x 的最后一位数字,并将它"推入"到 rev 的后面.最后,rev 将与 x 相反. 要在没有辅助堆栈 / 数组的帮助下…
[刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接 000-十大经典排序算法…