由买买提看人间百态

topics

全部话题 - 话题: std
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
x********4
发帖数: 405
1
来自主题: Business版 - mean/ std
if you are talking about mean over std of an asset's return, it is called
sharp ratio. the higher the better. it means that for a given unit of risk
you are taking, how much expected return you are going to get...

higher
l**********t
发帖数: 5754
2
来自主题: Business版 - mean/ std
stdev/mean is called coefficient of variance.
not sure about mean/std
m******t
发帖数: 273
3
I know that the shape and scale can be calculated from meand and std. dev.
I have tried this, but the QQ plot result is very bad.
I know this calculation works if it is gamma.
But, It is truncated gamma.
Thanks !
j*******d
发帖数: 55
4
ratio of an expected value and an std. deviation, 就是: mu/sigma, 数学上有
什么术语表达吗?我只知道skewness 和kurtosis,不知道这个一次项的叫什么,或者
根本就没有这么个术语?谢谢。
c********h
发帖数: 330
5
没有算过truncated gamma的mle,可以表示成mean和std的函数吗?
要是可以就结了
我猜是没戏,一般location的mle都是什么最大最小统计量吧
b*****s
发帖数: 11267
6
来自主题: Statistics版 - Expected value 和 std难题求教
order statistics ,这里类比 uniform吧

std
x******a
发帖数: 6336
7
来自主题: Programming版 - C++ problem
I got thousands problems on the following piece of code "dumpfile.h" when I
compile under cygwin. it is ok under visual stduio... can anyone help?
Thanks!
#include
#include
#include //ostream_iterator
#include //cerr
#include //std::copy
template
void dump_to_file(const char* filename, const std::vector& v_d){
std::ofstream ofs(filename);
if(!ofs){
std::cerr<<"Unable to open the file to write!n";
return ;... 阅读全帖
c*******9
发帖数: 6411
8
来自主题: Programming版 - compile error
get compile error from following code, any ideas?
thanks...
.....
set seen;
.....
pair::iterator, bool> res = seen.insert(str);
c:\apps\mvs8\vc\include\functional(143) : error C2784: 'bool
std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits>
&)' : could not deduce template argument for 'const std::_Tree<_Traits>
&' from 'const std::string'
1> c:\apps\mvs8\vc\include\xtree(1372) : see declaration of
'std::operator <'
1> c:\apps\mvs8\vc\include\fu... 阅读全帖
t***q
发帖数: 418
9
【 以下文字转载自 Programming 讨论区 】
发信人: treeq (treeq), 信区: Programming
标 题: 天,如何能让程序转得快点?有包子。
发信站: BBS 未名空间站 (Fri Feb 27 23:26:22 2015, 美东)
天,如何能让程序转得快点?
原帖在这里:
http://www.mitbbs.com/article_t0/Programming/31381809.html
主要是要做 title matching.
有两个 file, file A 162283 行 X 12 列。 File B 3695 行 X 6 列。用 A 的 第五
列和 B的第四列进行比较, 对 B 的第四列的每一行, 从 A的 那 162283 行中 找出
与之最相似的那一行。A 的第五列和 B 的第四列都是些影视作品的 title, 是一些长
短不一的 string. 我用的是 Levenshtein algorithm 算每一对string 的相似度,再
把相似度排序,从高到低,找出相似度最大的那一个 string, 也就是影视作品的
title, ... 阅读全帖
t***q
发帖数: 418
10
【 以下文字转载自 Programming 讨论区 】
发信人: treeq (treeq), 信区: Programming
标 题: 天,如何能让程序转得快点?有包子。
发信站: BBS 未名空间站 (Fri Feb 27 23:26:22 2015, 美东)
天,如何能让程序转得快点?
原帖在这里:
http://www.mitbbs.com/article_t0/Programming/31381809.html
主要是要做 title matching.
有两个 file, file A 162283 行 X 12 列。 File B 3695 行 X 6 列。用 A 的 第五
列和 B的第四列进行比较, 对 B 的第四列的每一行, 从 A的 那 162283 行中 找出
与之最相似的那一行。A 的第五列和 B 的第四列都是些影视作品的 title, 是一些长
短不一的 string. 我用的是 Levenshtein algorithm 算每一对string 的相似度,再
把相似度排序,从高到低,找出相似度最大的那一个 string, 也就是影视作品的
title, ... 阅读全帖
h*****f
发帖数: 248
11
来自主题: Programming版 - Re: L 电面 (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: henrysf (Henry), 信区: JobHunting
标 题: Re: L 电面
发信站: BBS 未名空间站 (Thu Oct 18 01:46:20 2012, 美东)
我写了以下的code, 之后就被拒了, 回信是说别的candidate写得比较好, 我还没看出
问题.
Additional requirements:
- The only operators you need to implement are +, -, *, and /.
However, your implementation should make it relatively easy to
add more operators.
- The calculator should accept floating point numbers and output
floating point numbers (i.e. when the input is 2 3 / the result
is 0.66667).
- ... 阅读全帖
v******y
发帖数: 84
12
来自主题: Programming版 - 前几天有人问rvalue reference的
这是我的理解,不对的请指出,谢谢
The usage of rvalue reference &&
Define a class
class MyClass{
public:
MyClass(){/*require for const MyClass cMyClass init. Without this default
constructor, const MyClass will have to be declared and defined as such:
const MyClass cMyClass=MyClass(). MyClass() here will call synthesized
constructor automatically generated by compiler. This synthesized
constructor can not directly initiate const. So following is illegal without
default constructor: const MyClass cMyClass;*/}
};... 阅读全帖
t***q
发帖数: 418
13
天,如何能让程序转得快点?
原帖在这里:
http://www.mitbbs.com/article_t0/Programming/31381809.html
主要是要做 title matching.
有两个 file, file A 162283 行 X 12 列。 File B 3695 行 X 6 列。用 A 的 第五
列和 B的第四列进行比较, 对 B 的第四列的每一行, 从 A的 那 162283 行中 找出
与之最相似的那一行。A 的第五列和 B 的第四列都是些影视作品的 title, 是一些长
短不一的 string. 我用的是 Levenshtein algorithm 算每一对string 的相似度,再
把相似度排序,从高到低,找出相似度最大的那一个 string, 也就是影视作品的
title, 加到 file B 对应的那一个title 那一行。再加入一个从file A 出来的对应的
一个id, 到 file B 里。算相似度前,我先对每个title 组成的string做预处理,去掉
“:”,”-“,”season”,”episode “ , 等一些词。... 阅读全帖
t***q
发帖数: 418
14
把 c++ 程序改成这样,快了许多,虽说程序不work,但至少说明,应该在算distance
之前就把 string processing 都做了:
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
size_t uiLevenshteinDistance(const std::string &s1, const std::string &s2)
{
const size_t m(s1.size());
const size_t n(s2.size())... 阅读全帖
r**a
发帖数: 536
15
来自主题: Programming版 - 菜鸟请教smart pointer
下面的code中,输出为"Constructor, Constructor, Destructor, 3" 前两个
constructors分别是create b1 and b2是出现的。第3个Destructor应该是对应到“b1
= b2;"。我的问题是此时b2已经被free掉了,为啥最后的结果是3呢?哪位大牛给解释
解释。谢谢了。
#include
#include
#include
#include
class StrBlob
{
public:
typedef std::vector::size_type size_type;
StrBlob();
StrBlob(std::vector &il);
size_type size() const { return data->size(); }
bool empty() const { return data->empty(); }
void push_... 阅读全帖
d****o
发帖数: 2
16
来自主题: JobHunting版 - 面试F家让先做programming puzzle
抛砖引玉
#include
#include
#include
const int kMaxK = 5;
const int kMaxN = 8;
const int kMaxS = 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5;
#define DEBUG(v) std::cerr << #v << " = " << (v) << "\n"
int N, K, max_state;
short top[kMaxS][kMaxK];
int G[kMaxS][kMaxK * (kMaxK - 1) + 1];
int src = 0, dst = 0;
int f[kMaxS];
int pow(int base, int power) {
int r = 1;
for (int i = 0; i < power; r *= base, ++i);
return r;
}
int get(int num, int d) {
for (int i = 0; i < d; num /= K, ++i)... 阅读全帖
d****o
发帖数: 2
17
来自主题: JobHunting版 - 面试F家让先做programming puzzle
抛砖引玉
#include
#include
#include
const int kMaxK = 5;
const int kMaxN = 8;
const int kMaxS = 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5;
#define DEBUG(v) std::cerr << #v << " = " << (v) << "\n"
int N, K, max_state;
short top[kMaxS][kMaxK];
int G[kMaxS][kMaxK * (kMaxK - 1) + 1];
int src = 0, dst = 0;
int f[kMaxS];
int pow(int base, int power) {
int r = 1;
for (int i = 0; i < power; r *= base, ++i);
return r;
}
int get(int num, int d) {
for (int i = 0; i < d; num /= K, ++i)... 阅读全帖
EM
发帖数: 715
18
来自主题: Programming版 - [C++ boost::interprocess] 讨论贴
在parent process里面建立一个{1,2,3}的set,然后在child process里面打印出来,编
译可以通过,但是为什么会有segmentation fault呢?读了大半天boost的东东也没搞
明白,请大侠指导一下
程序如下,编译如右:g++ -std=c++0x src.cc -lrt
#include
#include
#include
#include //std::system
#include
#include
#include
using namespace boost::interprocess;
//Main function. For parent process argc == 1, for child process argc == 2
int main(int argc, char **argv)
{
if(argc == 1... 阅读全帖
l********a
发帖数: 1154
19
来自主题: Programming版 - map析构

跟踪了2天才找到这个问题,难道dll内自定义的类不能使用stl容器吗?
像我这种定义的容器数据非指针,该怎么释放呢?
没有其他解决办法吗?我这个map没有跨dll传递啊?
在testGA类定义里面声明,
构造函数里面map.insert(make_pair())添加内容,使用完后立即clear(),
在析构函数内没有操作map,因为已经被clear()了,又不是指针,无法delete
下断后出错在~testGA的时候会调用~map,
testGA.dll!std::map,std::
allocator >,double,std::less char>,std::allocator > >,std::allocator char,std::char_traits,std::allocator > const ... 阅读全帖
h*****f
发帖数: 248
20
来自主题: JobHunting版 - 上一道我以前喜欢出的题目吧
not so efficient...
#include
#include
#include
#include
#include
#include
int compare(const std::string& v1, const std::string& v2) {
std::vector version1;
std::vector version2;
std::istringstream is1(v1);
std::istringstream is2(v2);
std::string token1;
std::string token2;
double d1, d2;
bool exist1 = true, exist2 = true;
while (true) {
if (exist1) exist1 = std::getline(is1, tok... 阅读全帖
N****w
发帖数: 21578
21
好像还不够多
这个 D 要是有类似的 web lib, Gtk-D, Qt lib,估计也会火
现在貌似还只有基本的 IO 和算法
但加上别的如果有人肯干也就是一年半载的体力活
std
* std.algorithm
* std.array
* std.base64
* std.bigint
* std.bind
* std.bitarray
* std.bitmanip
* std.boxer
* std.compiler
* std.complex
* std.contracts
* std.conv
* std.cover
* std.cpuid
* std.ctype
* std.date
* std.demangle
* std.encoding
* std.file
* std.format
* std.functional
* core.memory
* std.getopt
* s

发帖数: 1
22
来自主题: Programming版 - 请教高手一个C++问题
如果是C++11或以上的话,可以加一段std::hash>的specialization:
------------------------------------------
namespace std {
template
struct hash> {
template
inline static std::size_t CombineHashes(const TupleT &arg,
std::enable_if_t* = 0) {
std::size_t first_hash = CombineHashes(arg);
std::size_t second_hash = std::hash<
typename std::tuple_element阅读全帖
C***U
发帖数: 2406
23
#include
#include
#include
#define MAX 10000
int main(int argc, char *argv[]){
std::vector numbers1;
std::vector numbers2;
int k = atoi(argv[3]);
if(argc < 4)
std::cout << "we need 2 files and a number." << std::endl;
std::cout << "we need find " << k << "th number" << std::endl;
std::cout << "reading first array of numbers ..." << std::endl;
std::ifstream f1(argv[1]);
if(!f1){
std::cout << "cannot open... 阅读全帖
h**********c
发帖数: 4120
24
来自主题: Programming版 - C++一问
应该可以
说不清,JAVA也可以这么干。
#include
#include
class A {
public:
A(const std::string& _name):Name(_name) {}
const std::string Name;
const std::string getName () {
return Name;
}
};
class B:public A {
public:
B():A("It is B") {}
const std::string getName () {
return Name;
}
};
class C:public B {
public:
const std::string Name;
C():Name("It is C") {}
const std::string getName () {
return Name;
}
};
int main () {
A a("It is A");
B b;
C c;
... 阅读全帖
j********x
发帖数: 2330
25
来自主题: JobHunting版 - 新鲜G面筋(2)
写了一个小时,没考虑特别的corner case,O(num of intervals of "except"),用了
上面提到的binary search:
#include
#include
#include
#include
#include
struct compareable_interval {
int start;
int end;
int real_start;
int real_end;

compareable_interval(int lhs, int rhs) : start(lhs), end(rhs), real_
start(lhs), real_end(rhs) {
}
compareable_interval(int l, int r, int rl, int rr) : start(l), end(r),
real_start(rl), real_end(rr) {
}
b... 阅读全帖
j********x
发帖数: 2330
26
来自主题: JobHunting版 - 新鲜G面筋(2)
写了一个小时,没考虑特别的corner case,O(num of intervals of "except"),用了
上面提到的binary search:
#include
#include
#include
#include
#include
struct compareable_interval {
int start;
int end;
int real_start;
int real_end;

compareable_interval(int lhs, int rhs) : start(lhs), end(rhs), real_
start(lhs), real_end(rhs) {
}
compareable_interval(int l, int r, int rl, int rr) : start(l), end(r),
real_start(rl), real_end(rr) {
}
b... 阅读全帖
y**b
发帖数: 10166
g**u
发帖数: 583
28
来自主题: JobHunting版 - Google Onsite 面经
用stl的priority_queue写了下multi-way merge, 请大家拍砖。
其中: myPair的第一个就是要存储的值, 第二个表示ownership.
/*
*multiple way merge using the priority_heap
*/
#include "vector"
#include "queue"
class myPair{
friend std::ostream & operator<<(std::ostream & out, const myPair &p)
{
out<<" ( "< return out;
}
public:
myPair(int x, int y):_first(x),_second(y)
{
}
bool operator >(const myPair & p)const
{
return this->_fir... 阅读全帖
S**I
发帖数: 15689
29
来自主题: JobHunting版 - C++ Q83: 这个const_cast什么意思?
I bet if you run a debugger for this example, you will see that both a and *
b have value 3 after "*b = 3", but the output of "std::cout << a" is still 2.
The reason is when compiler sees "std::cout << a", since a is declared as
const and initialized to 2, it may replace this statement with "std::cout <<
2". The compiler never bothers to check whether the value of a has been
modified before "std::cout << a". This is a valid optimization and many
compilers do it.
Change you code to the following ... 阅读全帖
m*********a
发帖数: 3299
30
const char i='x';
const char *cp=&i;
char *p;
p=const_cast(cp);
std::cout<<&i<<" "< address
*p='y';
std::cout<<*p< std::cout<<*cp< std::cout< 同样的
char i='x';
const char *cp=&i;
char *p;
p=const_cast(cp);
std::cout<<&i<<" "<阅读全帖
m******e
发帖数: 353
31
来自主题: JobHunting版 - one amazon interview problem
#include
#include
void countOnesAndZeros(int &numZeros, int &numOnes, const std::vector &
sequence) {
numOnes = 0;
numZeros = 0;
for(size_t i = 0; i sequence[i] == 1 ? ++ numOnes : ++ numZeros;
}
}
int trimLeft(const std::vector &sequence, int start, int numToTrim, int
untilSeenSymbol) {
int trimCnt = 0;
while(start + trimCnt >= 0 && start + trimCnt < (int) sequence.size() &&
numToTrim > 0) {
if(sequenc... 阅读全帖
y*******n
发帖数: 129
32
来自主题: JobHunting版 - 一道有关String的面试题
store list of words in hashtable
key: signature
value: list of words with the same signature.
recurse on input to find solution
code:
typedef std::map > Dict;
typedef std::map >::iterator DictIter;
void descramble(const std::string& input, std::string& output, Dict& dict) {
if (input.empty()) {
std::cout << output << std::endl;
} else {
for (size_t i=1; i<=input.size(); i++) {
std::string ... 阅读全帖
d******i
发帖数: 7160
33
sorry又来了,就是想把事情想明白。
下面的code在vc6没问题。
可是放在vs2008下就出错。
应该是断在了这句(当i=4时):
pop_heap(x.begin(), x.end());
完整代码如下:
#includeXXX
void testK2()
{
srand(time(NULL));
vector x(5, 1.0);
make_heap(x.begin(), x.end());
for (int i=0; i<100; i++) {
double n=double(rand())/RAND_MAX;
if (n x.back()=n;
pop_heap(x.begin(), x.end());
}
cout< }
for (size_t i=0; i cerr<阅读全帖
s*********t
发帖数: 1663
34
来自主题: JobHunting版 - 问个题
我也写一个,欢迎大牛们拍砖。
std::vector threeKids(std::vector& arr, int n)
{
std::vector ret;
std::map > S1;
std::map > S2;
std::map >::iterator t;
for(size_t i=0; i for(t = S2.begin(); t != S2.end(); t++ ){
if( t->first + arr[i] == n){
for(size_t j=0; jsecond.size(); j++)
ret.push_back( t->se
w********s
发帖数: 1570
35
来自主题: JobHunting版 - 问一道G onsite题
频率统计法
ABCDEF,每次triplet XYZ
记录X的频率,Y的频率,Z的频率
X可能包含了ABCD,A出现的频率是10/20,B:6/20,C:3/20,D:1/20
ABCD如果都相同,那么就是20
ABCD如果其中2个字母相同,就是16,13,11,9,7,4
3个字母相同,结果是19,14,10,17
都不相同就是10,6,3,1
注意10可能是abbb或者abcd,那么用Y的频率来判断哪种情况。
std::string triplet()
{
static std::string password = "google";
std::set digits;
while (digits.size() < 3)
{
int d = rand() % 6;
digits.insert(d);
}
std::string result;
for (std::set::const_iterator it = digits.begin(); it != digits.end
... 阅读全帖
h*****f
发帖数: 248
36
来自主题: Programming版 - double's equality
C++ FAQ建议用以下的code來test whether 2 doubles are equal
#include /* for std::abs(double) */
inline bool isEqual(double x, double y)
{
const double epsilon = /* some small number such as 1e-5 */;
return std::abs(x - y) <= epsilon * std::abs(x);
// see Knuth section 4.2.2 pages 217-218
}
想问为什么要用:
return std::abs(x - y) <= epsilon * std::abs(x);
而不是用:
return std::abs(x - y) <= epsilon;
Knuth section 4.2.2提到
std::abs(x - y) <= epsilon * std::abs(x) || std::abs(x - y) <= epsilon * std
:... 阅读全帖
t**r
发帖数: 3428
37
来自主题: Programming版 - 问个c++问题
你必須去改那個類,
for your reference:
#include
#include
struct A {
std::string s;
A() : s("test") {}
A(const A& o) : s(o.s) { std::cout << "move failed!n";}
A(A&& o) : s(std::move(o.s)) {}
};
A f(A a) {
return a;
}
struct B : A {
std::string s2;
int n;
// implicit move contructor B::(B&&)
// calls A's move constructor
// calls s2's move constructor
// and makes a bitwise copy of n
};
struct C : B {
~C() {}; // destructor prevents ... 阅读全帖
e********2
发帖数: 495
38
报错
required from 'std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::
tuple<_Args1 ...>, std::tuple<_Args2 ...>) [with _Args1 = {const int&}; _
Args2 = {}; _T1 = const int; _T2 = std::pair&>]'
class Employee {
public:
int id;
int importance;
std::vector subordinates;
};
class Solution_690 {
public:
int aux(std::unordered_map&>>&
parents, int ind) {
int res = parents[ind].first;
for (auto& t : par... 阅读全帖
r***e
发帖数: 29
39
来自主题: JobHunting版 - BBC 编程风格面试题,求指教
最后个人标准答案
#ifndef _ROMON_HEADER_
#define _ROMON_HEADER_
#define _DEBUG_
#include
#include
//ROMON digits
const std::string ROMON_DIGITS[] = {"I","IV","V","IX", "X","XL","L","XC","C"
,"CD","D","CM","M" };
//ROMON scale
const int ROMON_SCALE[] = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900,
1000};
const int ROMON_MAX = 3999;
const int ROMON_MIN = 1;
class RomanNumeralGenerator
{
public:
virtual std::string generator(int num) = 0;
};
class CRoman : public RomanNumeralGene... 阅读全帖
t****t
发帖数: 6806
40
来自主题: Programming版 - 形参可以直接使用私有数据成员?
18.4 Dynamic memory management [lib.support.dynamic]
1 The header defines several functions that manage the allocation of
dynamic storage in a program.
It also defines components for reporting storage management errors.
Header synopsis
namespace std {
class bad_alloc;
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
new_handler set_new_handler(new_handler new_p) throw();
}
void* operator new(std::size_t size) throw(std::bad_alloc);
void* operator ne... 阅读全帖
k***p
发帖数: 115
41
来自主题: Programming版 - 请教boost::any compile错误。
我的compiler是gcc 4.7。 多谢
$g++ testAny.cpp -o testAny
testAny.cpp: In function ‘void AnyTesting3()’:
testAny.cpp:66:54: error: no match for ‘operator=’ in ‘myPropertySet.std:
:map<_Key, _Tp, _Compare, _Alloc>::operator[], boost
::any, std::less >, std::allocator std::basic_string, boost::any> > >((* & std::basic_string(((
const char*)"BarrType"), (*(const std::allocator*)(& std::allocator<
char>()))))) = (BarrierType)... 阅读全帖
b***i
发帖数: 3043
42
来自主题: Programming版 - C++11痛并快乐着
最近用asio, 好不容易把boost一个tcp server的例子改成了不用boost,只用C++11。
其中的改动有
boost::bind -> std::bind, _1 -> std::placeholders::_1, boost::asio::xxx ->
asio::xxx,
boost::system::error_code -> asio::error_code, high_resolution_timer.
expires_at(std::chrono::high_resolution_clock::time_point::max());
主要问题是网上大部分的例子都是用boost,而编译器去年才全部支持C++11。改动的地
方也不知道对不对,只知道语法对了。
最后,生成一个例子程序来测试能不能把server停了,退出程序,这个退出的功能需要
用一个线程,3秒后呼叫io_service.stop(); 所以线程如下
void asyncStop(Server& server) {
using namespace std::literals;
std... 阅读全帖
E*****7
发帖数: 128
43
来自主题: JobHunting版 - 回文数的问题
Algorithm:
Store each input into std::vector v;
Compare its first (i=0) and last element(j=v.size()-1)
if (v[i] != v[j]) return false;
Compare its 2nd and 2nd to last element
if (v[i+1] != v[j-1]) return false;
until i meets j
======= C++ Code (efficient and O(N) =========
#include
#include
bool isPalindrome(const std::vector &v) {
size_t len = v.size();
if ( len < 2 )
return false;
int i = 0;
int j = len - 1;
while ( i < j ) {
... 阅读全帖
m**p
发帖数: 189
44
来自主题: JobHunting版 - thread-safe blockingqueue
这个怎么样?
#include
#include
#include
#include
template
class Queue
{
public:
T pop()
{
std::unique_lock mlock(mutex_);
while (queue_.empty())
{
cond_.wait(mlock);
}
auto item = queue_.front();
queue_.pop();
return item;
}
void pop(T& item)
{
std::unique_lock mlock(mutex_);
while (queue_.empty())
{
cond_.wait(mlock);
}
item = queue_.front();
que... 阅读全帖
x******a
发帖数: 6336
45
来自主题: Programming版 - 请问关于overloading <<
I found if I make the second parameter const, i.e.std::ostream& operator<<(
std::ostream& os, const str& s), it worked now. what happened?
std::ostream& operator<<(std::ostream& os, str& s){
//obliterate existing value(s)
for (str::size_type i=0; i!=s.size(); ++i)
os<
return os;
}
class str{
public:
typedef std::vector::size_type size_type;
//constructors
str();
str(size_type n,char c);
str(const char* cp);
template str(In b, ... 阅读全帖
s*******f
发帖数: 1114
46
来自主题: JobHunting版 - Facebook Phone Inteview + 流程请教
//A. Given an arbitrary tree, can you print it level by level (with each
level
//printed on the same line).Define your own tree node structure, can be
//binary tree or n-ary tree.
struct Node{
int d;
std::vector children;
};
void PrintByLevel(Node *r){
if (!r)
return;
std::queue q;
q.push(r);
int pre_count = 1;
int count = 0;
while (!q.empty()){
Node *p = q.front();
for (std::vector::const_iterator ci = p-
>children.begin(); ci != p->children.end(); ++ci){
q.push(*ci);
++cou... 阅读全帖

发帖数: 1
47
Over the course the study, Hahm unmasked some myths common about Asian
Americans. She said, “There’s a perception that Asian Americans in
particular aren’t practicing sexually risky behaviors. But we found that
Asian American young women are at risk of high STDs. For instance, Asian
American women had a higher prevalence of STDs than White women in both 1995
(10.4% vs. 7.7) and 2001 (13.5% vs. 8.3%). The incidence of STDs (not
diagnosed with STDs in 1995, but developed STIs in 2001) among Asi... 阅读全帖
c*****e
发帖数: 74
48
题目:一个board上,每个cell是一个字母,从一个cell出发,可以到它相邻的8个cell
。这样可以在board上walk。但是一个walk上一个cell不能出现2次。
要求:找出所有的可以由walk得到到的不同的单词。编程中可以自己假定一些已经实现
的方法。
以前面试被问到过,时间浪费在一些细节(怎么解决8个相邻cell的问题,怎么检查是
否一个cell重复出现)上了,当时也没有充分利用try,没答好,主要还是对递归、Try
的接口不熟。今天好好想了想该怎么写,下面是我的代码,花了不少时间,觉得收获不
少。好好写写这道题应该对面试很有帮助的。
有问题帮忙指出一下。
---------------------------------
class CTryNode;
class CTry
{
public:
CTryNode* Advance(CTryNode* pNode, char ch);
CTryNode* Back(CTryNode* pNode);
string GetValue(pTryNode* pNode);
bool IsCurr... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)