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", "af", "bd", "be", "bf", "cd", "ce", "cf"].
  vector<string> letterCombinations(string digits) {
string trans[] = {"", " ", "abc", "def", "ghi", "jkl",
"mno", "pqrs", "tuv", "wxyz"};
vector<string> set;
string seq;
Generater(trans, digits, , seq, set);
return set;
}
void Generater(string trans[], string& digits,
int deep, string& result, vector<string>& set)
{
if(deep == digits.size())
{
set.push_back(result);
return;
}
int curDig = digits[deep] - ;
for(int i =; i < trans[curDig].size(); i++)
{
result.push_back(trans[curDig][i]);
Generater(trans, digits, deep+, result, set);
result.resize(result.size() -);
}
}

Letter Combinations of a Phone Number的更多相关文章

  1. [LintCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  2. 69. Letter Combinations of a Phone Number

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  3. 【leetcode】Letter Combinations of a Phone Number

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  4. [LeetCode][Python]17: Letter Combinations of a Phone Number

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numb ...

  5. Letter Combinations of a Phone Number:深度优先和广度优先两种解法

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  6. leetcode-algorithms-17 Letter Combinations of a Phone Number

    leetcode-algorithms-17 Letter Combinations of a Phone Number Given a string containing digits from 2 ...

  7. 《LeetBook》leetcode题解(17):Letter Combinations of a Phone Number[M]

    我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...

  8. Letter Combinations of a Phone Number - LeetCode

    目录 题目链接 注意点 解法 小结 题目链接 Letter Combinations of a Phone Number - LeetCode 注意点 可以不用按字典序排序 解法 解法一:输入的数字逐 ...

  9. LeetCode: Letter Combinations of a Phone Number 解题报告

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  10. [LeetCode]Letter Combinations of a Phone Number题解

    Letter Combinations of a Phone Number: Given a digit string, return all possible letter combinations ...

随机推荐

  1. GoldenGate中使用strcat和strext进行数据转换

    在OGG中可以对源字段的内容进行合并或拆分,从而实现类似于“ETL”的功能.strcat(s1,s2,s3,,,):用于合并字串:strext(str, start, end):用于获取指定位置的字串 ...

  2. IOS界面切换

    好吧!表示这几天要实现  phonegap 打开IOS原生界面,因此也查询了一些方案. 有如下几种: 第一种:navigationcontroller //进入下层 [self.navigationC ...

  3. 【python练习】截取网页里最新的新闻

    需求: 在下面这个网页,抓取最新的新闻,按天划分. http://blog.eastmoney.com/13102551638/bloglist_0_1.html 实现方法1:使用递归 import ...

  4. CSS 3D旋转 hover 后设置transform 是相对于正常位置

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. MySQL的高级查询

    高级查询 1.连接查询(对列的扩展) 第一种形式select * from Info,Nation #会形成笛卡尔积 select * from Info,Nation where Info.Nati ...

  6. Java 获取APK安装程序的包名

     Java 获取APK安装程序的包名核心的两个类:  ResPackage ApkDecoder  package com.temobi.util; import java.io.File; impo ...

  7. ajax 中的一些方法应用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. hdu 2094

    ps: 原本听说用set容器做是最好的...然而我并不懂..就用C语言做了...就是先输入赢得一组和输的一组,然后把重复的删掉,再比较赢得一组里没有出现在输的一组里的人数,如果是1就是YES,其他就是 ...

  9. IOS9适配 MARK

    最近做了iOS 9的适配,程序出现大量警告也做了些处理,写出来分先给大家. 一.iOS 9适配 问题一: <Error>: CGContextSaveGState: invalid con ...

  10. 强引用strong和弱引用weak的定义

    1.强引用表示从属关系,引用对象拥有被引用的对象.弱引用则暗示引用对象不拥有被引用的对象.一个对象的寿命是由它被强引用多少次来决定的.只要对象还存在强引用,就不会释放该对象. 注意:但是对象之间的引用 ...