leetcode (17) - Letter Combinations of a Phone Number
来源:互联网 发布:迷你小钢炮淘宝地址 编辑:程序博客网 时间:2024/06/08 00:38
因为不知道
void getLetterCom(char** res,char* digits,char* tmp,int index,char map[10][5],int *top){ int i,digit=digits[index]-'0';char* letters; if(digits[index]==0){ letters=(char*)malloc(sizeof(char)*index); tmp[index]=0;strcpy(letters,tmp);printf("%s", tmp); res[*top]=letters;(*top)++; return; } for(i=0;map[digit][i];i++){ tmp[index]=map[digit][i]; // printf("%c,", tmp[index]); getLetterCom(res,digits,tmp,index+1,map,top); }}char** letterCombinations(char* digits, int* returnSize) { // number 0-9 char map[10][5]={" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; char** res,*tmp; int num=1,length=0,top=0; //计算一共有多少种可能,然后malloc while(digits[length]){ if(digits[length]=='0' || digits[length]=='1')continue; else if(digits[length]=='7' || digits[length]=='9')num*=4; else num*=3; length++; } res=(char**)malloc(sizeof(char*)*num); if(length==0){ *returnSize=0; return res; } tmp=(char*)malloc(sizeof(char)*length); getLetterCom(res,digits,tmp,0,map,&top); *returnSize=top; return res;}
0 0
- LeetCode: Letter Combinations of a Phone Number
- LeetCode Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [Leetcode] Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [LeetCode]Letter Combinations of a Phone Number
- LeetCode-Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- LeetCode - Letter Combinations of a Phone Number
- LeetCode:Letter Combinations of a Phone Number
- LeetCode | Letter Combinations of a Phone Number
- leetcode Letter Combinations of a Phone Number
- Leetcode: Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- leetcode: Letter Combinations of a Phone Number
- java使用spring国际化文字
- tablelayout 和view pager 底部菜单添加文字和图片(view)方法
- 一天一条Linux指令-hexdump
- 【iOS开发】获取网络数据或者路径的文件名
- 安卓使用轻量级数据库SQL 简单用法
- leetcode (17) - Letter Combinations of a Phone Number
- python日常学习二------变量和数据类型
- 【原创】【NOIP】摆花问题
- linux内核通用提权漏洞expliot 脏牛Dirty COW
- StringBuiler与String的区别
- 查看ubuntu信息
- php屏蔽语法错误提示
- RecycleView GridLayoutManager效果
- Effective C++改善程序与设计的55个具体做法