谷歌java面试题_关于google的JAVA面试题我的解法

我在ASP里用脚本试了一下,想了一个不错的算法,计算到:199981 用了24秒,原文用了203秒?

后来又试了一下50亿内的计算,结果如下:

2006-05-29 16:04:35

621

1=getCount1Show(1)0

199981=getCount1Show(199981)26

199982=getCount1Show(199982)26

199983=getCount1Show(199983)26

199984=getCount1Show(199984)26

199985=getCount1Show(199985)26

199986=getCount1Show(199986)26

199987=getCount1Show(199987)26

199988=getCount1Show(199988)26

199989=getCount1Show(199989)26

199990=getCount1Show(199990)26

200000=getCount1Show(200000)26

200001=getCount1Show(200001)26

1599981=getCount1Show(1599981)242

1599982=getCount1Show(1599982)242

1599983=getCount1Show(1599983)242

1599984=getCount1Show(1599984)242

1599985=getCount1Show(1599985)242

1599986=getCount1Show(1599986)242

1599987=getCount1Show(1599987)242

1599988=getCount1Show(1599988)242

1599989=getCount1Show(1599989)242

1599990=getCount1Show(1599990)242

2600000=getCount1Show(2600000)419

2600001=getCount1Show(2600001)419

13199998=getCount1Show(13199998)2164

后面的数字是所用的秒数,再后来时间太长了,就停了进程~

另一个解法,得到的效果:

2006-05-29 18:17:55

1:1[0]

199981:199981[38]

199982:199982[38]

199983:199983[38]

199984:199984[38]

199985:199985[38]

199986:199986[38]

199987:199987[38]

199988:199988[38]

199989:199989[38]

199990:199990[38]

200000:200000[38]

200001:200001[38]

1599981:1599981[254]

1599982:1599982[254]

1599983:1599983[254]

1599984:1599984[254]

1599985:1599985[254]

1599986:1599986[254]

1599987:1599987[254]

1599988:1599988[254]

1599989:1599989[254]

1599990:1599990[254]

2600000:2600000[400]

2600001:2600001[400]

13199998:13199998[1505]

35000000:35000000[3153]

35000001:35000001[3153]

35199981:35199981[3168]

35199982:35199982[3168]

35199983:35199983[3168]

35199984:35199984[3168]

35199985:35199985[3168]

35199986:35199986[3168]

35199987:35199987[3168]

35199988:35199988[3168]

35199989:35199989[3168]

35199990:35199990[3168]

35200000:35200000[3168]

35200001:35200001[3168]

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2006-05-29 16:03

浏览 765

评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值