由买买提看人间百态

topics

全部话题 - 话题: phonenum
(共0页)
c***2
发帖数: 838
1
来自主题: JobHunting版 - map numbers to strings
Ok. I play it further to get a utility program.
==================================================
/* telwords.c

Given a telephone number (or any number),
print all possible words based on
digits-letters mapping from telephone key pads.
*/

#include
#include
#include
static char *digitsmaps[]={
"0",
"1",
"ABC",
"DEF",
"GHI",
"JKL",
"MNO",
"PQRS",
"TUV",
"WXYZ",
"#",
NULL
};

void doPrintTelephoneWo... 阅读全帖
u***8
发帖数: 1581
2
103页。那个电话号码对应字母的题目。为什么for loop里面,要在最后判断是不是等
于0 或者是1?
getCharKey(int , int )不就是可以把一个数字对应的3个之一的字母给返回了么?那
么是0或者是1,就返回空的不就够了。为什么要判断下0 1,这个不懂。
updates: code在这里
static final int PHONE_NUMBER_LENGTH = 7;
void printTelephoneWords(int[] phoneNum) {

char[] result = new char [PHONE_NUMBER_LENGTH];
doPrintTelephoneWords( phoneNum, 0, result);
}
void doPrintTelephoneWords(int[] phoneNum, int curDigit, char[] result) {
if ( curDigit == PHONE_NUMBER_LENGTH) {
System.out.println(new S... 阅读全帖
c*******e
发帖数: 8624
3
先做一个辅助table
select phonenum ,
min(calltime) as min_calltime
from your_table
group by 1
然后数的时候用case
select a.phonenum ,
count(case when a.calltime between b.min_calltime and b.min_calltime
+ 1
then a.phonenum else null end) as day1_cnt ,
...
from your_table a
join table_above b
on a.phonenum = b.phonenum
group by 1
order by 1 ;
i******7
发帖数: 421
4
哦.我可能没有说清楚.实际上这个calltime的格式是:mm/dd/yyyy hh:mm:ss的.所以觉
得那个+1可能不work.如果格式包括时间,该怎么写呢?

发信人: cheungche (你不乖), 信区: Database
标 题: Re: 请教一下这个report的query应该怎么样写?
发信站: BBS 未名空间站 (Mon Oct 18 18:44:55 2010, 美东)
先做一个辅助table
select phonenum ,
min(calltime) as min_calltime
from your_table
group by 1
然后数的时候用case
select a.phonenum ,
count(case when a.calltime between b.min_calltime and b.min_calltime
+ 1
then a.phonenum else null end) as day1_cnt ,
...
from your_tabl... 阅读全帖
j***y
发帖数: 2074
5
来自主题: JobHunting版 - map numbers to strings
又看了一会儿,似乎有些明白,的确是巧妙的递推。但有些疑问:
1. char result[PHONE_NUMBER_LENGTH];应改为char result[PHONE_NUMBER_LENGTH+1]?
2. void printTelephoneWords( int phoneNum[] ){
char result[PHONE_NUMBER_LENGTH];
doPrintTelephoneWords( phoneNum, 0, result );
}似乎应该改为:
void printTelephoneWords( int phoneNum[] ){
char result[PHONE_NUMBER_LENGTH+1]; /* +1 for the string-ending 0x0
character */
for (int i = 0; i < 3; i++) {
doPrintTelephoneWords( phoneNum, 0, result );
}
}
否则出来的似乎只是da、db、dc而已。
我不太懂算法和... 阅读全帖
g***l
发帖数: 18555
6
这个是最简单的
select phonenum,
DateDiff(dd, '12/31/2009',phonedate)
as DayNumber,
1 as PhoneCount
into PhoneCountTemp
from table
select phonenum,DayNumber, sum(phonecount) as PhoneCount
from PhoneCountTemp
group by phonenum, daynumber
order by phonenum, daynumber
i******7
发帖数: 421
7
SQL 2008
有这样一个table:
phonenum calltime rowID
1 2/4/2010 1
4 2/8/2010 2
2 6/18/2010 3
2 6/20/2010 5
3 8/20/2010 6
4 2/9/2010 7
4 2/11/2010
… … …
我现在要做一个report,就是显示每个phonenum每天收到多少个call,只需要显示前90天
.比如phone1的第一个call是2/4.从那天开始的往后90天,每天收到多少个call.phone4
的第一个call是2/8.那么分别是day1有一个call, day2有一个call,day4有一个call.
具体report的格式如下.
phonenum 1st day 2nd day 3rd day 4th day … 90th day
1 1
2 1 1
3 ... 阅读全帖
p********7
发帖数: 549
8
来自主题: JobHunting版 - Amazon第一轮面试
map 先用grep和find找到正确格式phonenumber and
their ID, and put those information you get and put them itto map with the
data. To put them to map:
map.find(Userid), if yes get phonenum and date, to update it; if not insert.
j***y
发帖数: 2074
9
来自主题: JobHunting版 - map numbers to strings
又琢磨了半天,你是对的。确实不需要再加一个循环,我搞错了。
就以你原来的程序为例:
doPr(p, 0, res) ->
currDigIdx=0, i=0, res[0]='d', doPr(p, 1, res) ->
currDigIdx=1, i=0, res[1]='a', doPr(p, 2, res) ->
print("da"), return ->
/* recursion-cycle finished for doPr(p, 2, res), but not finished yet for
doPr(p, 1, res) */
currDigIdx=1, i=1, res[1]='b', doPr(p, 2, res) ->
print("db"), return ->
currDigIdx=1, i=2, res[1]='c', doPr(p, 2, res) ->
print("dc"), return ->
/* now doPr(p, 1, res) is finished, return to the for-loop in doPr(p, 0,,
res... 阅读全帖
R**y
发帖数: 72
10
题目如下,要求recursive 和 non recursive解法
write a program that given a 7 digit telephone number, could print all
possible combinations of letters that each number could represent.
second part: if the telephone number changes to 12 digits one
recursive 解法很清晰,建立一个字典,然后递归就好了。
iterative 解法,我就卡住了,google了一下,有一个解法如下:
private static ArrayList processOneNumber(ArrayList input, int[] phoneNum,
int currentNum) {
ArrayList output = new ArrayList();
int numberToProcess = phoneNum[currentNum];
char c;
... 阅读全帖
p********7
发帖数: 549
11
来自主题: JobHunting版 - Amazon第一轮面试
我懒得再写一次了,我觉得最后一个题目先find grep然后hash,我觉得用map更好些,
map
j***y
发帖数: 2074
12
来自主题: JobHunting版 - map numbers to strings
老大,程序看不太懂,能否加点注释啊?
比如当i为0的时候,result[0]=0吧?因为digitsmaps[0]==""。这时候递归调用
doPrintTelephoneWords(phoneNum, 1, result)是要达成一个什么目的呢?
真是看不明白啊。
c***2
发帖数: 838
13
来自主题: JobHunting版 - map numbers to strings
1) from facebook
2) result[..+1] you can do that, but not necessary since C does index from 0
, the last idx is alwasy reseved for 0.
char try[2];
Either of these are fine:
try[0]='a';
try[1]='b';
try[2]='\0';
or strcpy(try,"ab");
3) curDigit is better named currentidx (from phoneNum[])
w*n
发帖数: 5041
14
来自主题: PennySaver版 - 那里有计分钟的电话DEAL
你到这里: http://www.net10.com/phones.jsp?nextPage=&task=phonedoc&phoneNum=0&hasflash=YES&b=n
输入zipcode, 不知道买$20电话送300分钟再加送200分钟的还在不在(也不知道跟
zipcode有没有关系); 然后mrrebates.com 有15% cashback; coupon code在这里: http://www.retailmenot.com/view/net10.com, 我当时是合用了2个, -$3的和送car charger的.
反正加税18刀多一点, cashback另拿. 我爸妈最后通话时间都没用完~ 还拿了一手机(
虽然是很土的平板吧, 指导他们转机什么的很方便)
w*n
发帖数: 5041
15
来自主题: PennySaver版 - 那里有计分钟的电话DEAL
你到这里: http://www.net10.com/phones.jsp?nextPage=&task=phonedoc&phoneNum=0&hasflash=YES&b=n
输入zipcode, 不知道买$20电话送300分钟再加送200分钟的还在不在(也不知道跟
zipcode有没有关系); 然后mrrebates.com 有15% cashback; coupon code在这里: http://www.retailmenot.com/view/net10.com, 我当时是合用了2个, -$3的和送car charger的.
反正加税18刀多一点, cashback另拿. 我爸妈最后通话时间都没用完~ 还拿了一手机(
虽然是很土的平板吧, 指导他们转机什么的很方便)
(共0页)