由买买提看人间百态

topics

全部话题 - 话题: count2
(共0页)
i*********7
发帖数: 348
1
来自主题: JobHunting版 - Leetcode OJ的编译器是?
哇。leetcode大神直接来回复我。。。orz...
是那题 add binary的。你的test cases里面有25%左右过不了。
但是我把那些过不了的test case放到我自己的x-code ide上,又得到和你expected一
样的答案。
string addBinary(string a, string b) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int next = 0;
int length = max(a.size(),b.size());
char *res = new char[length + 1];
memset(res,0,length);
int count1,count2;
count1 = a.size() - 1;
count2 = b.size() - 1;
while(count1 >= 0 || count2 >= 0)
{
... 阅读全帖
p*g
发帖数: 141
2
来自主题: JobHunting版 - Leetcode OJ的编译器是?
同意
1. 我試了一下樓主的程序
OJ上large test裡 出錯的情況都是輸出的string 最後有幾個其他字符
感覺是內存釋放問題?
2. 如果用c++ 的string,
直接用下面這樣的 ,
當然, 其他高手可能有更好的辦法;
string rv;
int next = 0;
int length = max(a.size(),b.size());
int count1,count2;
count1 = a.size() - 1;
count2 = b.size() - 1;
while(count1 >= 0 || count2 >= 0)
{
int b1,b2;
b1 = b2 = 0;
if(count1 >= 0)
b1 = a[count1] - '0';
if(count2 >= 0)
b2 = b[count2] - '0';
int curbit = b1+b2+next... 阅读全帖
p*****2
发帖数: 21240
3
来自主题: JobHunting版 - DP与Greedy的题

是。因为做过很多类似的DP题,上来就往DP那里想了。做的时候才发觉DP帮助不明显。
但是测试用例也都过了,就提交了。这题证明greedy可以也得花一些时间。不是很直观
。如果只是有思路的话,还是会在greedy和dp只见纠缠。感觉比赛的时候很难掌握呀。
另外,上一下greedy的代码。
public class test2 {
static String s;
static int k;
static HashSet pairs = new HashSet();
static boolean isForbidden(char[] arr) {
Arrays.sort(arr);
return pairs.contains(new String(arr));
}
static int Play(String str) {
int count = 0;
int count1 = 0;
int count2 = 0;
int j = 0;
for (int... 阅读全帖
C*****H
发帖数: 7927
4
法律的问题我是不太懂。
但是编程写code run simulation的事情稍微懂一点,
看到过一篇很好的分析牌例的文章,讲述在庄家有AA而自己没有K的情况下的过手,
感谢作者,但因为不确定他本人是不是愿意被提起,所以只引用内容在此:
If we assume cards are randomly dealt, my simulation shows, given that
zhuang does have AA and doesn't have any K, the probability of having at
least one k from his partner is around .55 with 100,000 times of simulation.
Histogram shows this prob is stable.The following is my code and you're
welcome to test and give comments.
R code:
count<-NA
count1<-0
count2<-0
for(j in 1:1000... 阅读全帖
C*****H
发帖数: 7927
5
法律的问题我是不太懂。
但是编程写code run simulation的事情稍微懂一点,
看到过一篇很好的分析牌例的文章,讲述在庄家有AA而自己没有K的情况下的过手,
感谢作者,但因为不确定他本人是不是愿意被提起,所以只引用内容在此:
If we assume cards are randomly dealt, my simulation shows, given that
zhuang does have AA and doesn't have any K, the probability of having at
least one k from his partner is around .55 with 100,000 times of simulation.
Histogram shows this prob is stable.The following is my code and you're
welcome to test and give comments.
R code:
count<-NA
count1<-0
count2<-0
for(j in 1:1000... 阅读全帖
C*****H
发帖数: 7927
6
☆─────────────────────────────────────☆
Grandmaster (Garry Kasparov) 于 (Tue Sep 24 08:54:56 2013, 美东) 提到:
其实我不赞同举报作弊的做法,但我想了下,还是这么做了,回头谈谈我的想法。
证据证言推论我都有,没来得及说已经被人一通辱骂威胁。版主不喜欢我继续在这里说
话,我就此打住。如果有兴趣知道我的证据证言证人推论过程的,梦版见。
☆─────────────────────────────────────☆
ninedays (九天) 于 (Tue Sep 24 09:13:19 2013, 美东) 提到:
Evidence, please. Also better to first state the facts, i.e., what happened,
then the reason you think they were cheating. Two parts basically: 1) facts
; 2) your opinion.

☆─────────... 阅读全帖
b**a
发帖数: 1118
7
I am using sth like this now:
DECLARE @count2 int
SET @count2 = 10000
WHILE @count2 >= 10000
BEGIN
DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
temp OPTION (MAXDOP 1)
SELECT @count2 = @@ROWCOUNT
END
and i really need it to run faster...
b**a
发帖数: 1118
8
I am using sth like this now:
DECLARE @count2 int
SET @count2 = 10000
WHILE @count2 >= 10000
BEGIN
DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
temp OPTION (MAXDOP 1)
SELECT @count2 = @@ROWCOUNT
END
and i really need it to run faster...
d*********g
发帖数: 154
9
刚写的,796ms过了。我这个计算largest bar area的函数写得复杂了,吃个饭回来看
看楼上那个简洁代码的思路。
public int maximalRectangle(char[][] matrix)
{
if(matrix == null || matrix.length==0) return 0;
int[] count1 = new int[matrix[0].length];

for(int j = 0; j < matrix[0].length; ++j)
count1[j] = matrix[0][j] - '0';

int result = 0;
for(int i = 1; i < matrix.length; ++i)
{
result = Math.max(result, processRow(count1));
int[] count2 = new int[matrix[0].length];
for(int j = 0; ... 阅读全帖
c********t
发帖数: 5706
10
来自主题: JobHunting版 - storm8 online code给跪了
这样行不?
public int count2(char[] str) {
int n = str.length, count = 1;
for (int i = 1; i < n;i++) {
if (str[i] != str[i-count]) {
count = i+1;
}
}
return count>n/2? n/2: count;
}
c********t
发帖数: 5706
11
来自主题: JobHunting版 - storm8 online code给跪了
这样行不?
public int count2(char[] str) {
int n = str.length, count = 1;
for (int i = 1; i < n;i++) {
if (str[i] != str[i-count]) {
count = i+1;
}
}
return count>n/2? n/2: count;
}
B*****l
发帖数: 1078
12
升什么级,印度升级多就是应为eb3i 比 eb2i 多很多, 中国又没有什么eb3c。o 反正
降级也是count2次 根本就没有加速自己eb2, 我要是可以降级我也降,虽然帮不了整
个ebC 但自己快多了。
c*********2
发帖数: 2752
13
来自主题: EB23版 - Double counted?
count2次应该是官方的counting system的问题, 并不可能发2张card给你。
d*g
发帖数: 16592
14
来自主题: Tennis版 - 怎么样打球能打出节奏来?
就是比如你coutn 1的时候,永远是球拍12点的位置,count2时候是1点位置,
count3时候是2点位置,count 4时候是4点位置,count5时候是6点位置,
count6时候是8点到9点的击球位置击球,count7是球拍伸出去离身体最远位置,
count8是左手握住拍喉位置,count9是放松复原等等。
每个人可以不一样,但是要有这样的counting对应的位置。
J*****n
发帖数: 107
15
sorry,网址点进去好像不行
在noodler's那个tab里面的第二页,Noodler's Eye-Dropper Bottled Fountain Pen Ink w/Free Pen (4.5 oz) 这个选项,进去要在下拉菜单找Heart of darkness
不过这里也不免运费,还是去amazon凑够25刀吧。
黑暗之心
http://store.swisherpens.com/shared/StoreFront/default.asp?CS=swisher&StoreType=BtoC&Count1=468990504&Count2=386130928
n******7
发帖数: 12463
16
没用过NoSQL,现在遇到两个问题,都需要储存、查询大量的大数据,考虑是不是可以
用上NoSQL
问题大概是这样的,我有很多docs,每个doc有很多words,很多words出现频率很高,
words在一个doc里面出现顺序不重要。docs本身有一些注释
我希望有个database可以
1. 存储这些docs。我琢磨做成 word1 -> {doc1:count,doc2:count2} 这样的
2. 存储一个新doc时,可以update已有的key-> value 列表。如果遇到新的word,就建
立新的key-> value 关联
3. 比较docs。这个比较麻烦。比如给一个doc,我想很快知道哪些docs跟它有一样的
key。如果有必要,我还想查询substring。比如有个文档有mitbbs这个词,可能我想把
mit和bbs这两个key也包括进来
我本来觉得用SQL应该可以搞定,但是这两个问题里面,可能的词汇表都很大(>10^9)
。 问题1稍好点,文档之间很多高频词是差不多的,问题2词汇表更大,文档之间的关
联更弱。这个用NoSQL有戏吗?看了一下Redis,好像就是个只有... 阅读全帖
(共0页)