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"].
/**
* Return an array of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
char* digit2Letter(char digit){
switch(digit){
case '':
return "abc";
case '':
return "def";
case '':
return "ghi";
case '':
return "jkl";
case '':
return "mno";
case '':
return "pqrs";
case '':
return "tuv";
case '':
return "wxyz";
default:
return "";
}
} char** letterCombinations(char* digits, int* returnSize) {
char** returnArray = NULL;
if(*digits == '\0') return returnArray; char* returnElem = malloc(sizeof(char)*sizeof(strlen(digits)));
returnArray = malloc(sizeof(char*)*);
backTracking(digits, returnArray, returnSize, returnElem, ); return returnArray;
} void backTracking(char* digits, char** returnArray, int* returnSize, char* returnElem, int pElem){
if(*digits == '\0'){
(*returnSize)++;
char* elem = malloc(sizeof(char)*pElem);
memcpy(elem, returnElem, sizeof(char)*pElem);
elem[pElem] = '\0';
printf("elem[0] = %d, elem[1] = %d\n",elem[],elem[]);
returnArray[*returnSize-] = elem;
return;
} char* str = digit2Letter(*digits);
int len = strlen(str);
for(int i = ; i < len; i++){
returnElem[pElem] = str[i]; backTracking(digits+, returnArray, returnSize, returnElem, pElem+ );
}
}

17. Letter Combinations of a Phone Number (backtracking)的更多相关文章

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

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

  2. Leetcode 17. Letter Combinations of a Phone Number(水)

    17. Letter Combinations of a Phone Number Medium Given a string containing digits from 2-9 inclusive ...

  3. 刷题17. Letter Combinations of a Phone Number

    一.题目说明 题目17. Letter Combinations of a Phone Number,题目给了下面一个图,输入一个字符串包括2-9,输出所有可能的字符组合. 如输入23所有可能的输出: ...

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

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

  5. [leetcode]17. Letter Combinations of a Phone Number手机键盘的字母组合

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...

  6. [LeetCode] 17. Letter Combinations of a Phone Number 电话号码的字母组合

    Given a string containing digits from 2-9inclusive, return all possible letter combinations that the ...

  7. 17. Letter Combinations of a Phone Number

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

  8. [leetcode 17]Letter Combinations of a Phone Number

    1 题目: Given a digit string, return all possible letter combinations that the number could represent. ...

  9. Java [leetcode 17]Letter Combinations of a Phone Number

    题目描述: Given a digit string, return all possible letter combinations that the number could represent. ...

随机推荐

  1. oracle 内连接(inner join)、外连接(outer join)、全连接(full join)

    转自:https://premier9527.iteye.com/blog/1659689 建表语句: create table EMPLOYEE(EID NUMBER,DEPTID NUMBER,E ...

  2. E2040 Declaration terminated incorrectly - System.ZLib.hpp(310) ZLIB_VERSION

    [bcc32 Error] System.ZLib.hpp(310): E2040 Declaration terminated incorrectly  Full parser context    ...

  3. 解决eclipse新建项目看不到src/main/java目录办法

    1.eclipse->window->preferences->java->compiler->选择本地要用的Java版本 2.eclipse->window-&g ...

  4. cordova-config.xml配置应用图标

    1. <icon src="res/icon/ios/browser.png"/> 2.规格: iphone平台一般要求3种规格的图片:1x.2x.3x,也是就Icon ...

  5. ubuntu 使用命令行登录oracle

    1.检查环境变量设置 echo $ORACLE_HOME 2.配置oracle数据库信息,将oracle地址端口等信息放在$ORACLE_HOME/network/admin目录下的tnsnames. ...

  6. jquery接触初级-----juqery DOM操作 之二

    DOm 操作之: 1.1  children(),这个函数只是查找元素的子元素,而不考虑其他后代元素 <body> <p title="请选择你最喜欢的水果"&g ...

  7. Lazarus中Windows单元问题

    在程序中加入Windows 单元后,经常会使一些过程和函数莫名其妙的报错,这是因为Windows单元很多函数,过程 与sysutils 单元重名 ,所以一般要把windows 引用放在 sysutil ...

  8. RESET MASTER和RESET SLAVE使用场景和说明,以及清除主从同步关系

    mysql主从复制中,需要将从库提升为主库,需要取消其从库角色,这可通过执行RESET SLAVE ALL清除从库的同步复制信息.包括连接信息和二进制文件名.位置.从库上执行这个命令后,使用show ...

  9. Spring AOP demo 和获取被CGLIB代理的对象

    本文分为两部分:1)给出Spring AOP的一个例子(会使用CGLIB代理):2)给出获取被CGLIB代理的原始对象. 1.Spring AOP Demo 这部分参考了博文(http://www.v ...

  10. Haskell语言学习笔记(91)Comprehension Extensions

    Comprehension Extensions 关于解析式的相关语言扩展. List and Comprehension Extensions 24 Days of GHC Extensions: ...