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. js event

    event jquery获取: 在jquery中调用函数中最多只能有event这一个参数,所有的值在event.data中可以获取. $('select').click(function(event) ...

  2. springboot 停止

    因springboot内嵌tomcat或jetty使得我们没法去操作服务: 因此,常常是服务起来后,要重启时会端口占用,我们只能无情的kill掉端口. 不过spring也设置有配置停止的请求: App ...

  3. linux与linux远程桌面

    https://blog.csdn.net/m0_37343696/article/details/79252979

  4. JSP基本_JavaBeans

    1.JavaBeansとはJavaBeansとは.ある機能を一つにまとめたクラスです.Webアプリケーションでは.JavaBeansは主にデータ操作に使用します.データ管理のプログラムをJavaBea ...

  5. java字符串常量池——字符串==比较的一个误区

    转自:https://blog.csdn.net/wxz980927155/article/details/81712342   起因 再一次js的json对象的比较中,发现相同内容的json对象使用 ...

  6. Delphi中TApplication详解(转仅供自己参考)

    转自:http://blog.sina.com.cn/s/blog_4d6f55d90100bmv9.html TApplication是用于Delphi应用程序的类型,该类在单元forms中声明.T ...

  7. jwt-auth错误小结

    我用的是:"tymon/jwt-auth": "1.0.0-rc.1" 根据官方网站http://jwt-auth.readthedocs.io安装,并且ven ...

  8. Linux:使用互斥量进行线程同步

    基础知识 同步概念 所谓同步,即同时起步,协调一致.不同的对象,对"同步"的理解方式略有不同.如,设备同步,是指在两个设备之间规定一个共同的时间参考:数据库同步,是指让两个或多个数 ...

  9. 【BUG记录】记一次游戏越来越卡的BUG

    U3D的MOBA项目,测试过程中,10分钟以后,游戏帧率开始缓慢下降,约3-5分钟后,由60帧下降到小于10帧,编辑器模式. 打开profiler,看到CPU占用非常高,每帧都有24K的GC, 时间占 ...

  10. Linux创建SSH信任关系

    Linux服务器创建信任关系可以解决远程执行命令.远程传输文件多次手工输入的麻烦.可以实现环境一键打包备份. 测试环境 SuSE 手工创建 假设服务器A与B间要建立信任关系.用户想从服务器A免密码登录 ...