avatar
韩国人也搞封面党# Joke - 肚皮舞运动
t*n
1
在做coursera 斯坦福那门算法课的作业,本来程序要跑10个小时,经过优化,只要4秒
钟跑完,还是很有成就感的啊,而且在工作中有时候看到程序跑的超慢,应该也许可以
用算法和数据结构进行优化的吧。我觉得面试考算法,还是比让你做个前端的表格啥的
更能考出智商高低。菜鸟一家之言,请大牛们解惑。
avatar
y*e
2
Ctrip.com International, Ltd. (ADR) (NASDAQ:CTRP) added 0.07% to $52.15.
The company reported that its third-quarter net income attributable to
shareholders was RMB320 million or US$48 million in the third quarter of
2010, up 70% year-on-year. Earnings per ADS were RMB 2.11 or US$0.31, up
from RMB 1.32 last year.
Net revenues were RMB812 million or US$121 million for the third quarter
of 2010, up 49% year-on-year.
Total revenues were RMB863 million or US$129 million, representing a 48%
increase from the same period in 2009.
Analysts polled by Thomson Reuters expected the company to report earnings
of US$0.24 per share on revenues of US$116.85 million. Analysts’ estimates
typically exclude special items.
avatar
y*n
3
上弦和调整快门速度的先后顺序有讲究么,我的是bessa R
avatar
c*n
4
avatar
j*8
5
贴贴你的代码,看看啥神奇的改动从10小时减到4秒了

【在 t********n 的大作中提到】
: 在做coursera 斯坦福那门算法课的作业,本来程序要跑10个小时,经过优化,只要4秒
: 钟跑完,还是很有成就感的啊,而且在工作中有时候看到程序跑的超慢,应该也许可以
: 用算法和数据结构进行优化的吧。我觉得面试考算法,还是比让你做个前端的表格啥的
: 更能考出智商高低。菜鸟一家之言,请大牛们解惑。

avatar
x*x
6
avatar
p*p
7
这和旁轴不旁轴没关系,要看快门模块的设计
一些老机器强调要先调快门再上弦,现在的机器基本没这个必要

【在 y****n 的大作中提到】
: 上弦和调整快门速度的先后顺序有讲究么,我的是bessa R
avatar
c*n
8
avatar
p*r
9
刷题很有用啊,尤其是做自己project的时候,
至于给公司干活,那就算了吧,
干得再好,还不如去kiss几下ass提拔的快。

【在 t********n 的大作中提到】
: 在做coursera 斯坦福那门算法课的作业,本来程序要跑10个小时,经过优化,只要4秒
: 钟跑完,还是很有成就感的啊,而且在工作中有时候看到程序跑的超慢,应该也许可以
: 用算法和数据结构进行优化的吧。我觉得面试考算法,还是比让你做个前端的表格啥的
: 更能考出智商高低。菜鸟一家之言,请大牛们解惑。

avatar
y*n
10
第四季业绩预测不及分析师预期.
avatar
b*g
11
上无忌去问问。每个机器都不一样。

【在 p**p 的大作中提到】
: 这和旁轴不旁轴没关系,要看快门模块的设计
: 一些老机器强调要先调快门再上弦,现在的机器基本没这个必要

avatar
N*K
12
cao...

【在 c******n 的大作中提到】

avatar
r*l
13
说刷题无用的人也许本来那些东西都已经知道了,人家写出来的程序本来就是4秒钟的
那个版本。你经过刷题将10小时改进到4秒钟,显然刷题对你来说很有用。这个就跟小
马过河一样,老牛说水很浅,但是小松鼠照样能淹死。

【在 t********n 的大作中提到】
: 在做coursera 斯坦福那门算法课的作业,本来程序要跑10个小时,经过优化,只要4秒
: 钟跑完,还是很有成就感的啊,而且在工作中有时候看到程序跑的超慢,应该也许可以
: 用算法和数据结构进行优化的吧。我觉得面试考算法,还是比让你做个前端的表格啥的
: 更能考出智商高低。菜鸟一家之言,请大牛们解惑。

avatar
w*s
14
no volume after hour. tomorrow see the direction. cc just started, it
indicated no slow down expected after the expo.

【在 y*****e 的大作中提到】
: Ctrip.com International, Ltd. (ADR) (NASDAQ:CTRP) added 0.07% to $52.15.
: The company reported that its third-quarter net income attributable to
: shareholders was RMB320 million or US$48 million in the third quarter of
: 2010, up 70% year-on-year. Earnings per ADS were RMB 2.11 or US$0.31, up
: from RMB 1.32 last year.
: Net revenues were RMB812 million or US$121 million for the third quarter
: of 2010, up 49% year-on-year.
: Total revenues were RMB863 million or US$129 million, representing a 48%
: increase from the same period in 2009.
: Analysts polled by Thomson Reuters expected the company to report earnings

avatar
x*r
15
re

【在 r******l 的大作中提到】
: 说刷题无用的人也许本来那些东西都已经知道了,人家写出来的程序本来就是4秒钟的
: 那个版本。你经过刷题将10小时改进到4秒钟,显然刷题对你来说很有用。这个就跟小
: 马过河一样,老牛说水很浅,但是小松鼠照样能淹死。

avatar
x*o
16
beat不beat,无所谓,主要看MM如何解读。
avatar
t*n
17
哦,有道理,对我来说还是很有用的

【在 r******l 的大作中提到】
: 说刷题无用的人也许本来那些东西都已经知道了,人家写出来的程序本来就是4秒钟的
: 那个版本。你经过刷题将10小时改进到4秒钟,显然刷题对你来说很有用。这个就跟小
: 马过河一样,老牛说水很浅,但是小松鼠照样能淹死。

avatar
t*n
18
给公司干活,可以写在简历上,比如,说我用某某算法,令这个项目的运行速度加快了
1000倍
不过我们老板会说, 别花时间想怎么优化了,就brute force, 15分钟写出来,能跑就
行,赶时间赶时间

【在 p**r 的大作中提到】
: 刷题很有用啊,尤其是做自己project的时候,
: 至于给公司干活,那就算了吧,
: 干得再好,还不如去kiss几下ass提拔的快。

avatar
t*n
19
import java.util.HashMap;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.File;
import java.util.*;
public class Cluster4{
public static void main(String args[]) throws FileNotFoundException,
IOException{
long startTime = System.currentTimeMillis();
String line;
String path = "/Users/***/documents/java/coursera_2/week_2/
problem_2/clustering_big.txt";
File nodeFile = new File(path);
if(!nodeFile.exists()) {
System.out.println("Failed to find file");
//do something
}
FileReader fr = new FileReader(nodeFile);
BufferedReader textReader = new BufferedReader(fr);
ArrayList arr = new ArrayList();
while ((line = textReader.readLine()) != null) {
if(line.length() > 0){
arr.add(line);
}
}//end while loop
Graph c = new Graph(arr);
int result = c.run(3);
System.out.println("cluster size is " + result);
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
System.out.println("executing time: " + elapsedTime);
}// end method main
}// end class Clustering
class Graph{
public int clusterCount = 0;
public int labelLen = 0;
public ArrayList edges = new ArrayList();
//symbol map : 1100 : [1,4,7] symbol mapped with the node id list
// node map: 1 : Node object
// nodes: [1,2,3,4...] node id
public HashMap> symbolMap = new HashMap<
Integer,ArrayList>();
public ArrayList nodes = new ArrayList();
public HashMap nodeMap = new HashMap();
public Graph( ArrayList arr){
int pos = 0;
for(String s:arr){
String[] line = s.split("\s+");
if (line.length == 2){
this.clusterCount = Integer.parseInt(line[0]);
this.labelLen = Integer.parseInt(line[1]);
} else{
String ss = String.join("", line);
int name = Integer.parseInt(ss, 2);
int id = this.nodes.size() + 1;
Node a = new Node(name, id, ss);
this.nodes.add(id);
this.nodeMap.put(id, a);
if(this.symbolMap.containsKey(name)){
this.symbolMap.get(name).add(id);
} else {
this.symbolMap.put(name, new ArrayList());
this.symbolMap.get(name).add(id);
}// end if else
}// end if else
}// end for loop to populate edges and nodeMap
// System.out.println("nodes: " + this.nodes);
// for (Map.Entry e:this.nodeMap.entrySet()){
// ((Node)e.getValue()).show();
// }// end for loop
}// end Graph constructor
public int run(int k){
ArrayList masks = generate(this.labelLen);
for (int n: this.nodes){
System.out.println("now starting from node " + n);
// System.out.println("cluster size now: " + this.clusterCount);
Node curr = this.nodeMap.get(n);
if (!curr.explored){
ArrayList tmp = new ArrayList();
curr.explored = true;
tmp.add(curr);
int p = 0;
int arrSize = 1;
while(p != arrSize){
Node head = tmp.get(p);
tmp.set(p, null);
p++;
for (int mask: masks){
if (this.symbolMap.containsKey((head.name)^mask)){
for (int id: this.symbolMap.get((head.name)^mask
)){
if(id != n && !this.nodeMap.get(id).explored
){
this.nodeMap.get(id).explored = true;
tmp.add(this.nodeMap.get(id));
arrSize++;
this.clusterCount--;
}
}
}
}// end for loop
}
}// end if
}// end for loop
return this.clusterCount;
}// end method run
public static ArrayList generate(int len){
ArrayList result = new ArrayList();
result.add(0);
int bit = 1;
for (int i = 0; i < len; i++){
result.add(bit<}// end for loop, add all one bit masks
for (int j = len - 1; j >0; j--){
for (int k = j - 1; k >=0; k--){
int one = ( 1 << j);
int two = ( 1 << k);
result.add(one^two);
}
}// end outer for loop, add all two bit masks
return result;
};
}// end class Cluster
class Node{
public int id;
public int name;
public int leader;
public int i ;// cluster size
public String s;
public ArrayList children;
public boolean explored;
public Node(int line, int id, String s){
this.id = id;
this.name = line;
this.i = 1;
this.s = s;
this.leader = id;
this.explored = false;
this.children = new ArrayList();
this.children.add(id);
}// end Node constructor
public static int dist(Node a, Node b){
int x = a.name;
int y = b.name;
return Integer.bitCount(x^y);
}// end method dist
public void show(){
System.out.println("node " + this.id + "; name: " + this.name + ";
string: " + this.s + "; leader: " + this.leader + "; size: " + this.i + ";
children: " + this.children);
}// end method show
public static void union(int i, int j, HashMap map){
Node a = map.get(i);
Node b = map.get(j);
Node small = null;
Node big = null;
// System.out.println("before union: ");
// a.show();
// b.show();
if(a.i <= b.i){
small = a;
big = b;
} else {
small = b;
big = a;
}// end if else
if(map.get(small.leader).children.size() > 0){
for(int child: map.get(small.leader).children){
map.get(child).leader = big.leader;
map.get(big.leader).children.add(child);
}// end for loop
}// end if
// System.out.println("mid union: ");
// a.show();
// b.show();
int newSize = map.get(big.leader).children.size();
for(int child: map.get(big.leader).children){
map.get(child).i = newSize;
}// end for loop
// System.out.println("after union: ");
// a.show();
// b.show();
}// end method union
}// end class Node
// result: cluster size is 6118
// executing time: 4365

【在 j*****8 的大作中提到】
: 贴贴你的代码,看看啥神奇的改动从10小时减到4秒了
avatar
t*n
20
不好意思,代码很乱很丑哈,反正做作业,只关心结果和运行时间。
是那门algorithms: design and analysis, part 2 的 第二周课后编程作业第二题。

【在 t********n 的大作中提到】
: import java.util.HashMap;
: import java.io.IOException;
: import java.io.FileNotFoundException;
: import java.io.FileReader;
: import java.io.BufferedReader;
: import java.io.File;
: import java.util.*;
: public class Cluster4{
: public static void main(String args[]) throws FileNotFoundException,
: IOException{

avatar
j*o
21
不是说刷题无用,而是现在的趋势是只看刷题,风气很不好。
把运行时间从10小时减到4秒的牛人,每个公司有1,2个就了不起了,多数人干的还是
搬砖的活。
avatar
t*n
22
没啥神奇改动,第一次brute force, 20万个node, 一一对比找edge, 然后union find;
20,0000 * 20,0000
然后看了课程论坛学到一找,generate bit mapping, 缩短为 300 * 20,0000 , 这
次半小时跑完
然后看到不少人都是几秒钟搞定,再次优化,不用union find,直接bfs,然后4.3秒就
跑完了

【在 j*****8 的大作中提到】
: 贴贴你的代码,看看啥神奇的改动从10小时减到4秒了
avatar
f*t
23
刷题有用的,练熟后实现一个简单算法并AC只需10分钟,而练之前恐怕两小时都不见得
能调对。即使工作中用不到各种hacky的算法,但写代码的手感也很重要,写代码bug比
较少,工作效率会非常高。所以现在大公司考算法题还是很有必要的,比design和
culture fit有意义的多。
avatar
t*n
24
是啊,基础知识会了,然后又能优化,那是最好,不会干活只会做题,就走极端了

【在 j******o 的大作中提到】
: 不是说刷题无用,而是现在的趋势是只看刷题,风气很不好。
: 把运行时间从10小时减到4秒的牛人,每个公司有1,2个就了不起了,多数人干的还是
: 搬砖的活。

avatar
p*r
25
你老板知道BF已经算不错的,
我老板只要出货,客户不抱怨就行。
速度慢?那最好,堆硬件,或者新一轮优化开发计划,都是钱啊。

【在 t********n 的大作中提到】
: 给公司干活,可以写在简历上,比如,说我用某某算法,令这个项目的运行速度加快了
: 1000倍
: 不过我们老板会说, 别花时间想怎么优化了,就brute force, 15分钟写出来,能跑就
: 行,赶时间赶时间

avatar
t*n
26
我老板一样一样一样地啊。。。
我觉得大家都应该像中国人一样,回家多少刷两题。。。

【在 p**r 的大作中提到】
: 你老板知道BF已经算不错的,
: 我老板只要出货,客户不抱怨就行。
: 速度慢?那最好,堆硬件,或者新一轮优化开发计划,都是钱啊。

avatar
t*n
27
更正一下,generate bit mapping, 缩短为 301 * 20,0000,
这301 的来源: (24 choose 0) + (24 choose 1) + (24 choose 2) = 1 + 24 + (24
! / (2! * 24!)) = 301

find;

【在 t********n 的大作中提到】
: 没啥神奇改动,第一次brute force, 20万个node, 一一对比找edge, 然后union find;
: 20,0000 * 20,0000
: 然后看了课程论坛学到一找,generate bit mapping, 缩短为 300 * 20,0000 , 这
: 次半小时跑完
: 然后看到不少人都是几秒钟搞定,再次优化,不用union find,直接bfs,然后4.3秒就
: 跑完了

avatar
h*e
28
我看你是螺丝拧多了拧出成就感来了。

【在 f*******t 的大作中提到】
: 刷题有用的,练熟后实现一个简单算法并AC只需10分钟,而练之前恐怕两小时都不见得
: 能调对。即使工作中用不到各种hacky的算法,但写代码的手感也很重要,写代码bug比
: 较少,工作效率会非常高。所以现在大公司考算法题还是很有必要的,比design和
: culture fit有意义的多。

avatar
f*t
29
不积跬步,无以至千里。刷题是练基本功。

【在 h****e 的大作中提到】
: 我看你是螺丝拧多了拧出成就感来了。
avatar
h*e
30
刚毕业的可以,工作10年了还积跬步?

【在 f*******t 的大作中提到】
: 不积跬步,无以至千里。刷题是练基本功。
avatar
w*9
31
学算法和刷算法题是两回事,你说的是学习算法,知其然切知其所以然,未来可以在工
作中应用。
而刷算法题则。。。
avatar
p*u
32

printf("Finished!");

【在 j*****8 的大作中提到】
: 贴贴你的代码,看看啥神奇的改动从10小时减到4秒了
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。