c***g 发帖数: 472 | 1 1 abstract和interface有什么区别, 鄙人长期不用java了,直接说不会
2 念了一段code, 问我什么问题
int f(int x) {
if(x==1) return 1;
return x*f(x-1);
}
然后问如果整数特别大的话, 怎么计算
3 设计一个chess game
4 一个int数组, 给你一个sum, 找出和是sum的两个int
听说amazon onsite的都发一个kindle啊, 是不是真的啊, 去过的人说说? | y******5 发帖数: 43 | 2 Thank you for your post.
2 念了一段code, 问我什么问题
int f(int x) {
if(x==1) return 1;
return x*f(x-1);
}
Problems:
(1). x<0
(2). overflow
4 一个int数组, 给你一个sum, 找出和是sum的两个int
solution 1: hash table, time complexity O(n), space complexity O(n)
solution 2: sort in-place, time complexity O(nlgn), space complexity O(1) | y***m 发帖数: 7027 | 3 2.负数死递归?
int f(int n){
int k=1 or -1;
while(k<=n){
x=x*k;
k++ or k--
}
return x;
}
3. 建各个棋子object定义属性,走法,建hashmap 存棋子位置坐标等,
queue存方案,多线程,优先级调度...
4. 遍历同时把元素和sum-元素值分别放两个hash A,B同时检查,如没找着,遍历B去找
A是否有 o(n)?
【在 c***g 的大作中提到】 : 1 abstract和interface有什么区别, 鄙人长期不用java了,直接说不会 : 2 念了一段code, 问我什么问题 : int f(int x) { : : if(x==1) return 1; : : return x*f(x-1); : } : 然后问如果整数特别大的话, 怎么计算 : 3 设计一个chess game
| a******7 发帖数: 106 | 4 about 3,
why do we need multi-thread, only two users, each have the turn at one
time.
why do we need hashmap, when you make move on board, you need check if
other chess is on certain position. So how about using a N*N array, with
each hold pointer to a chess object or NULL.
why do we need queue, a sequence of moves? One user's moves always
changes based on the other's moves, right? So I guess there gonna be
some decision tree, if the other make some decision, then we choose
certain path accordingly.
Comment if I'm wrong. Thanks!
【在 y***m 的大作中提到】 : 2.负数死递归? : int f(int n){ : int k=1 or -1; : while(k<=n){ : x=x*k; : k++ or k-- : } : return x; : } : 3. 建各个棋子object定义属性,走法,建hashmap 存棋子位置坐标等,
| w********p 发帖数: 948 | | d**e 发帖数: 6098 | 6 对这类游戏的设计,我一直有个疑问是到哪一步才停止计算哪一步才是最优的?
【在 a******7 的大作中提到】 : about 3, : why do we need multi-thread, only two users, each have the turn at one : time. : why do we need hashmap, when you make move on board, you need check if : other chess is on certain position. So how about using a N*N array, with : each hold pointer to a chess object or NULL. : why do we need queue, a sequence of moves? One user's moves always : changes based on the other's moves, right? So I guess there gonna be : some decision tree, if the other make some decision, then we choose : certain path accordingly.
| y***m 发帖数: 7027 | 7 发散式思考,选择最优策略,次优策略。。存list把。。。每个策略一个queue呢?这
样按原定计划就是一步步move out? 不过决策树也是挺好的解决模型吧
hashmap只是初步考虑,按棋子名取信息,不过你说的类似坐标方式二者结合可能会更
方便..
【在 a******7 的大作中提到】 : about 3, : why do we need multi-thread, only two users, each have the turn at one : time. : why do we need hashmap, when you make move on board, you need check if : other chess is on certain position. So how about using a N*N array, with : each hold pointer to a chess object or NULL. : why do we need queue, a sequence of moves? One user's moves always : changes based on the other's moves, right? So I guess there gonna be : some decision tree, if the other make some decision, then we choose : certain path accordingly.
|
|