由买买提看人间百态

topics

全部话题 - 话题: insertable
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
f*********i
发帖数: 197
1
来自主题: JobHunting版 - 问一道A家的面试题
如何实现stringbuilder中的insert
public void insert(string str, int index)
要求就是少用空间,问你要用什么数据结构。
我回答是用link, 具体问下来就是对每个char搞个link, 这样insert的时候可以保证
不影响其他的character,减少时间复杂度, 他看起来不满意,我想是因为空间要求太
大了?
后来我说用array,首先保证array足够长,然后如果要insert一个K长度的string到
index= n,那么就把n位以后的character往后移k位,他看起来还是不满意,说这个是O(
n)的时间复杂度。
我就无语了,后来扯到如果这个string超级长,有1G要怎么办,我说那样的话还是用
link,这样在local disk上创造100个文件,每个文件10MB,link中不保存实际的
string,只保留文件的地址,这样每次insert只修改某个特定文件,他听了还是不爽。
我后来想到是不是因为我没有说文件的balance问题,比如如果insert了一个100Mb的,
insert以后要再次分割。
结果我就倒在... 阅读全帖
y****z
发帖数: 52
2
来自主题: JobHunting版 - google 电面fast phone book loopup
你这个方法就是用两个HASHMAP 一个记录已经存在的 一个记录未存在的
所以这三个functions都是O(1) 空间O(N)
我想了一下 用trie最好
Class TrieNode{
boolean visited;
TrieNode[] children;
public TrieNode(){
visited=false;
children=new TrieNode[10];
}
}
插入的时候把该节点标记为visited
顺便记录父节点 然后扫描父节点下的所有子节点 如果都是visited就把父节点也标记
为visited
查找不说了
第三个方法的话就变成寻找一个visited=false的叶子就好了(假设号码10位数)
如果一个节点的visited=false 那么必然存在available的子节点
static class TrieNode{
boolean visited;
TrieNode[] children;

public TrieNode(){
visited=fal... 阅读全帖
d**********0
发帖数: 44
3
来自主题: Stock版 - Bing搜索下三烂,太不要脸了
http://googleblog.blogspot.com/2011/02/microsofts-bing-uses-goo
Microsoft’s Bing uses Google search results—and denies it
By now, you may have read Danny Sullivan’s recent post: “Google: Bing is
Cheating, Copying Our Search Results” and heard Microsoft’s response, “We
do not copy Google's results.” However you define copying, the bottom line
is, these Bing results came directly from Google.
I’d like to give you some background and details of our experiments that
lead us to understand just how Bi... 阅读全帖
d**********0
发帖数: 44
4
来自主题: Stock版 - Bing搜索下三烂,太不要脸了
http://googleblog.blogspot.com/2011/02/microsofts-bing-uses-goo
Microsoft’s Bing uses Google search results—and denies it
By now, you may have read Danny Sullivan’s recent post: “Google: Bing is
Cheating, Copying Our Search Results” and heard Microsoft’s response, “We
do not copy Google's results.” However you define copying, the bottom line
is, these Bing results came directly from Google.
I’d like to give you some background and details of our experiments that
lead us to understand just how Bi... 阅读全帖
g***l
发帖数: 2753
5
HR 43 IH
112th CONGRESS
1st Session
H. R. 43
To amend the Immigration and Nationality Act to eliminate the diversity
immigrant program and to re-allocate those visas to certain employment-based
immigrants who obtain an advanced degree in the United States.
IN THE HOUSE OF REPRESENTATIVES
January 5, 2011
Mr. ISSA introduced the following bill; which was referred to the Committee
on the Judiciary
A BILL
To amend the Immigration and Nationality Act to eliminate the diversity
immigrant program and t... 阅读全帖
d**********0
发帖数: 44
6
来自主题: SanFrancisco版 - Bing搜索下三烂,太不要脸了
http://googleblog.blogspot.com/2011/02/microsofts-bing-uses-goo
Microsoft’s Bing uses Google search results—and denies it
By now, you may have read Danny Sullivan’s recent post: “Google: Bing is
Cheating, Copying Our Search Results” and heard Microsoft’s response, “We
do not copy Google's results.” However you define copying, the bottom line
is, these Bing results came directly from Google.
I’d like to give you some background and details of our experiments that
lead us to understand just how Bi... 阅读全帖
d**********0
发帖数: 44
7
来自主题: Seattle版 - Bing搜索下三烂,太不要脸了
http://googleblog.blogspot.com/2011/02/microsofts-bing-uses-goo
Microsoft’s Bing uses Google search results—and denies it
By now, you may have read Danny Sullivan’s recent post: “Google: Bing is
Cheating, Copying Our Search Results” and heard Microsoft’s response, “We
do not copy Google's results.” However you define copying, the bottom line
is, these Bing results came directly from Google.
I’d like to give you some background and details of our experiments that
lead us to understand just how Bi... 阅读全帖
e*********y
发帖数: 29
8
来自主题: Database版 - 求助:找出现2次及以上的记录
没事做,给你完整的答案.呵呵! SQL Server 2005
create database neii
create table production
(
transactionid int primary key,
product char(25)
)
insert into production (transactionid, product) values ('1', 'apple')
insert into production (transactionid, product) values ('2', 'orange')
insert into production (transactionid, product) values ('3', 'apple')
insert into production (transactionid, product) values ('4', 'pear')
insert into production (transactionid, product) values ('5', 'watemellon')
insert into prod... 阅读全帖
i*****w
发帖数: 75
9
Try this:
--Last Week means SUNDAY - SATURDAY
declare @tbl table (name varchar(30), dt datetime )
insert into @tbl values('Apple', '2011/11/1')
insert into @tbl values('Apple', '2011/11/2')
insert into @tbl values('Apple', '2011/11/4')
insert into @tbl values('Orange', '2011/11/10')
insert into @tbl values('Orange', '2011/11/5')
insert into @tbl values('Apple', '2011/11/6')
insert into @tbl values('Banana', '2011/11/10')
SELECT NAME, COUNT(*) as Total_Count, SUM(case when dt between DATEADD(dd, ... 阅读全帖
k****s
发帖数: 1209
10
来自主题: Biology版 - 蜕皮素
原文在
http://www.skizit.biz/2013/07/21/ecdysone-insect-hormone-an-ind
Ecdysone Insect Hormone Switches on Disease
21 Jul 2013 | ECDYSONE
MORGELLONS:
INSECT HORMONE ECDYSONE TRIGGERS GENETIC CHANGES
TO BUILD NEW HAIR, SKIN, NAILS and CAUSE DISEASES
SkizitGesture-2013
Morgellons is a military grade entomological terror weapon being used to
torture and kill innocent civilians. The medical community has not been
informed about this disease and its complexity keeps it from being properly
identified, ... 阅读全帖
G*****h
发帖数: 320
11
拒绝拒稿的信件的通用样板,转发给各位做参考。
Feature Christmas 2015: The Publication Game
Rejection of rejection: a novel approach to overcoming barriers to
publication
BMJ 2015; 351 doi: http://dx.doi.org/10.1136/bmj.h6326 (Published 14 December 2015)
Cite this as: BMJ 2015;351:h6326
http://www.bmj.com/content/351/bmj.h6326
Cath Chapman, senior research fellow1, Tim Slade, associate professor1
Author affiliations
1NHMRC Centre of Research Excellence in Mental Health and Substance Use,
National Drug and Alcohol Resea... 阅读全帖
c*********u
发帖数: 607
12
来自主题: Statistics版 - 求问一个关于SQL的exist的问题
code如下:
create table nt (x int, y int);
insert into nt values (10, 10);
insert into nt values (10, 20);
insert into nt values (20, 10);
insert into nt values (30, 40);
insert into nt values (30, 50);
insert into nt values (30, 60);
insert into nt values (40, 70);
select * FROM nt WHERE exists
(SELECT t.* FROM nt t WHERE nt.x = t.x AND nt.y > t.y) ;
select * FROM nt WHERE exists
(SELECT nt.* FROM nt t, nt nt WHERE nt.x = t.x AND nt.y > t.y) ;
网上跑SQL的结果的链接在这里:
http://ideone.com/3CtqN9
第一个query的结果是... 阅读全帖
G*******e
发帖数: 219
13
来自主题: Medicalpractice版 - 求助,抽血致残! (转载)
http://news.nurse.com/apps/pbcs.dll/article?AID=2005505010320
Caution: Nerve Injuries During Venipuncture
Sue Masoorli, RN
Sunday May 1, 2005 Print Select Text Size: Comments
Share this Nurse.com Article
Share on facebook Share on twitter Share on email
Permanent damage can result
when a needle point makes
contact with a nerve.
"Nurse, I feel an electric shock going down my arm." Would this patient
complaint mean anything to you when you insert an IV catheter or draw blood?
This feeling of s... 阅读全帖
f**d
发帖数: 768
14
来自主题: Neuroscience版 - eBook: From computer to brain
这是一本计算神经科学的优秀著作,全文拷贝这里(图和公式缺),有兴趣的同学可以
阅读
如需要,我可以分享PDF文件(--仅供个人学习,无商业用途)
From Computer to Brain
William W. Lytton
From Computer to Brain
Foundations of Computational Neuroscience
Springer
William W. Lytton, M.D.
Associate Professor, State University of New York, Downstato, Brooklyn, NY
Visiting Associate Professor, University of Wisconsin, Madison
Visiting Associate Professor, Polytechnic University, Brooklyn, NY
Staff Neurologist., Kings County Hospital, Brooklyn, NY
In From Computer to Brain: ... 阅读全帖
z********g
发帖数: 241
15
来自主题: Military版 - 出大事了
insert into tb_satellite values('TS-3','0730H',' ','1','1',' ',' ');
insert into tb_satellite values('TS-4-A','074AH',' ','1','1',' ',' ');
insert into tb_satellite values('TS-4-B','074BH',' ','1','1',' ',' ');
insert into tb_satellite values('TS-5-A','075AH',' ','1','1', ' ',' ');
insert into tb_satellite values('TS-5-B','075BH',' ','1','1',' ',' ');
insert into tb_satellite values('TS-2','0720H',' ','1','1',' ',' ');
这些代号不清楚是测试数据还是真实数据。
看到了几个注视很有意思
--本地测试需要执行此脚本,上线时甲方DB中应该存在该表及对应数据
项目好像是外包出去的,... 阅读全帖
t******l
发帖数: 10908
16
来自主题: Military版 - 弦月的baby满月了吗?
这是 entry level insertable vibrator。
设计成有粗有细,我觉得是因为 insertable vibrator 设计给女性自己抽插循环时,
能有不断张弛的快感 。。。 而且 vibrator 是硬的 。。。 所以实际几把应该比最粗
的地方还粗一些。
长度应该看 insertable length 。。。 insertable length 不超过紫色环的位置,因
为那个是震动强度控制旋钮,不应该 insert 。。。 跟实际鸡巴应该比最终 insert
部分的长度。
这个 Durex Play Allure 的设计,是考虑正常 couple foreplay 的,设计成的应该接
近正常大小,震动也不太强烈 。。。 而不是给变态白男搞变态性奴的那种特大特粗号。
q*********u
发帖数: 280
17
来自主题: JobHunting版 - 一道linked list编程题
while里面少了一个和前面if一样的else吧

Question: Insert an element in order into a sorted linked list containing
integer data
Solution:
public Node insertInOrder(Node head, Node insert) {
if (head == null)
return null;
Node previous = head;
Node current = head.next;
if (current == null) {
if (previous.data < insert.data) {
previous.next = insert;
insert.next = null;
return head;
}
else {
insert.next = previous;
j*j
发帖数: 5564
18
来自主题: JobHunting版 - 一道linked list编程题
//...
}
current = insert;
insert.next = null;
return head;
}
最后这句 "current = insert;" 错了;这样并没有把insert插进去。
应该是:
previous.next = insert;
insert.next = NULL;
f********3
发帖数: 210
19
来自主题: JobHunting版 - 谁能给个hashset实现的例子么?
比如面试时,用set显然更好写。但hashset快。
hashset不是STL里面的,那么是不是所有的函数都得自己写。。。。感觉太麻烦了。。。
在这里看到个例子。那么面试时是不是还得这样写?
有没有好点的hashset的例子?多谢了
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
void lookup(const hash_set, eqstr>& Set,
const char* word)
{
hash_set, eqstr>::const_iterator it
= Set.find(word);
cout << word << ": "
<< (it != Set.end() ? "present" : "not prese... 阅读全帖
c********1
发帖数: 161
20
来自主题: JobHunting版 - LinkedIn电面
每store一个数n,就用n和每个已经存在数据结构中的数字想家求和,将这个和作为key
插入hashtable中,比如首先是empty,依次存入以下数,相对应的hashtable的key:
insert 2 -> ht: empty,
insert 3 -> ht: 5 (2+3)
insert 10 -> ht: 5, 12(2+10), 13(3+10)
insert 1 -> ht: 5, 12, 13, 3, 4, 11
insert 7 -> ht: 5, 12, 13, 3, 4, 11, 9, 10, 17, 8
insert .......
这样store的代价很高,但是twoSum却很容易了。
j********x
发帖数: 2330
21
来自主题: JobHunting版 - 面试题:GetNumber and ReleaseNumber
Effect of different data structures
The designer of the priority queue should take into account what sort of
access pattern the priority queue will be subject to, and what computational
resources are most important to the designer. The designer can then use
various specialized types of heaps:
There are a number of specialized heap data structures that either supply
additional operations or outperform the above approaches. The binary heap
uses O(log n) time for both operations, but allows peeking... 阅读全帖
v***a
发帖数: 365
22
来自主题: JobHunting版 - 最近没有什么新题

发现之前算法还不够优化,有overlap直接删点就是了
struct node {
int x, y;
node * left, * right, * fa;
};
node * insert(node * n, int x, int y) {
while (n && overlap(n, x, y)) {
if (n->x < x) x = n->x; if (n->y > y) y = n->y;
n = removeNode(n); // The hard part
}
if (n == NULL) {
n = new node;
n->x = x; n->y = y; n->left = NULL; n->right = NULL; n->fa = NULL;
if (root == NULL) root = n;
return n;
}
node * ret;
if (n->x < x) {
r... 阅读全帖
t****e
发帖数: 279
23
What is iterator invalidation?
Answer:
Insertion
Sequence containers
vector: all iterators and references before the point of insertion are
unaffected, unless the new container size is greater than the previous
capacity (in which case all iterators and references are invalidated) [23.2.
4.3/1]
deque: all iterators and references are invalidated, unless the inserted
member is at an end (front or back) of the deque (in which case all
iterators are invalidated, but references to elements are unaffe... 阅读全帖
u*****o
发帖数: 1224
24
题目是找LCA,不是BST,只是BINARY TREE, 有PARENT POINTER, 不用RECURSION
(话说LCA的题变形太多了!!简直目不暇接晕头转向啊)
1337大哥的SOLUTION在这里:
http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-
我想问问这个CODE是不是有问题呢?
Node *LCA(Node *root, Node *p, Node *q) {
hash_set visited;
while (p || q) {
if (p) {
if (!visited.insert(p).second)
return p; // insert p failed (p exists in the table)
p = p->parent; @@@@@@@@@@@
}
if (q) {
if (!visited.insert(q).second)
return q; // i... 阅读全帖
k***7
发帖数: 6
25
来自主题: JobHunting版 - 问一道题(9)
窗口大小为N
list大小为N,顺序存放数值以及记录元素在heap中的存放的Element address[这个不
随堆的调整而变化]
min heap大小为 N/2
max heap大小为 N-N/2
median为max heap顶上元素,access time O(1)
维护堆:list[0]要被下一个新数n替代
if(list[0]<=median){//list[0] is in max heap
remove(list[0], maxHeap);
if(n>maxHeap.top()) {
insert(n, minHeap);
insert(minHeap.top(), maxHeap);
minHeap.pop();
} else {
insert(n, maxHeap);
}
} else { //list[o] is in min heap
remove(list[0], minHeap);
if(n>maxHeap.top()) {
insert(n, minHeap... 阅读全帖
Q*****a
发帖数: 33
26
来自主题: JobHunting版 - airBnb电面面经
实现了4种方法
1: 直接遍历完整计算edit distance. 285 clocks.
2: 直接遍历,计算edit distance到 >k 就返回. 149 clocks.
3: Trie+shortcut edit distance. Build trie: 606 clocks, process: 6 clocks.
http://stevehanov.ca/blog/index.php?id=114
4: Generate delete k transformation. Build dict: 17033 clocks. process: 0
clocks.
但这里不仅需要生成delete k的pattern, 还需要生成所有delete 1..k-1的pattern,
否则不能handle如(chrome brome)的case
http://blog.faroo.com/2012/06/07/improved-edit-distance-based-s
#include "common.h"
class Trie {
public:
class TrieNo... 阅读全帖
Q*****a
发帖数: 33
27
来自主题: JobHunting版 - airBnb电面面经
实现了4种方法
1: 直接遍历完整计算edit distance. 285 clocks.
2: 直接遍历,计算edit distance到 >k 就返回. 149 clocks.
3: Trie+shortcut edit distance. Build trie: 606 clocks, process: 6 clocks.
http://stevehanov.ca/blog/index.php?id=114
4: Generate delete k transformation. Build dict: 17033 clocks. process: 0
clocks.
但这里不仅需要生成delete k的pattern, 还需要生成所有delete 1..k-1的pattern,
否则不能handle如(chrome brome)的case
http://blog.faroo.com/2012/06/07/improved-edit-distance-based-s
#include "common.h"
class Trie {
public:
class TrieNo... 阅读全帖
B********t
发帖数: 147
28
来自主题: JobHunting版 - 面经
自己写的最少行的版本,感觉背下来都要敲25分钟
class Solution {
public:
bool solveSudoku(vector> &v1, vector> &v2,
vector> &v3, vector > &board) {
for (int i = 0; i < board.size(); ++i)
for (int j = 0; j < board.size(); ++j)
if (board[i][j] == '.') {
int k = (i/3)*(board.size()/3) + j/3;
for (char c = '1'; c <= '9'; ++c) {
if (v1[i].find(c) == v1[i].end... 阅读全帖
h*****i
发帖数: 1017
29
#include
#include
using namespace std;
class binaryTree {

public:
int value;
int indx;
binaryTree *left;
binaryTree *right;
binaryTree(){
left = NULL;
right = NULL;
}
};
void insert(binaryTree *bTree, int num, int key){
if(bTree == NULL){
bTree = new binaryTree;
bTree->value = num;
bTree->indx = key;
printf("%d %dn",bTree->value,bTree->indx);
return;
... 阅读全帖
P****D
发帖数: 11146
30
无意中看到的,转过来大家晴天霹雳一下:
http://www.wired.com/threatlevel/2013/08/kwikset-smarkey-lock-v
Millions of Kwikset Smartkey Locks Vulnerable to Hacking, Say Researchers
By Kim Zetter
08.03.13
6:30 AM
LAS VEGAS – Locks that are used in millions of homes and residential
buildings worldwide and that are designed specifically to thwart hacking are
easily opened with both a screwdriver and wire, two researchers say.
Kwikset smartkey locks are certified Grade 1 security for residential use by
the Bui... 阅读全帖
F****n
发帖数: 3271
31
来自主题: EB23版 - 3012的BILL很短各位好好看看
AN ACT
To amend the Immigration and Nationality Act to eliminate the per-country
numerical limitation for employment-based immigrants, to increase the per-
country numerical limitation for family-sponsored immigrants, and for other
purposes.
Be it enacted by the Senate and House of Representatives of the United
States of America in Congress assembled,
SECTION 1. SHORT TITLE.
This Act may be cited as the `Fairness for High-Skilled Immigrants Act of
2011'.
SEC. 2. NUMERICAL LIMITATION TO ANY SINGL... 阅读全帖
B*********e
发帖数: 254
32
来自主题: TrustInJesus版 - the Story of the Adulteress in John 8
Bible Research > Textual Criticism > Story of the Adulteress
Concerning the Story of the Adulteress
in the Eighth Chapter of John
Biblical scholars are nearly all agreed that the Story of the Adulteress (al
so known as the Pericope Adulterae or the Pericope de Adultera) usually prin
ted in Bibles as John 7:53-8:11 is a later addition to the Gospel. On this p
age I present some extended quotations from scholarly works that explain the
reasons for this judgment. On another page I give an extract f... 阅读全帖
d***a
发帖数: 316
33
来自主题: CS版 - multimap 问题请教
一个用multimap的sample code,有些不明白为什么会是这样的输出结果。
code如下:
#include
#include
#include
#include
using namespace std;
typedef int KeyType;
typedef string ValType;
typedef pair Pair;
typedef multimap MapCode;
int main()
{
MapCode codes;

codes.insert(Pair(415, "San Francisco"));
codes.insert(Pair(510, "Oakland"));
codes.insert(Pair(718, "Brooklyn"));
codes.insert(Pair(718, "Staten Island"));
codes.ins... 阅读全帖
n**m
发帖数: 255
34
DROP TABLE A;
DROP TABLE B;
COMMIT;
CREATE TABLE A (ID INT);
CREATE TABLE B (ID INT);
COMMIT;

INSERT INTO A VALUES(1);
INSERT INTO A VALUES(2);
INSERT INTO A VALUES(3);
INSERT INTO A VALUES(NULL);

INSERT INTO B VALUES(3);
INSERT INTO B VALUES(4);
b*****e
发帖数: 364
35
来自主题: Database版 - 请教关于下面这个sql code地解释
Here is another example of such kind of subquary.
if object_id('##Table1')<>0 drop table ##Table1
Create table ##Table1 (
[Record Value] varchar(20), [Record Date] smalldatetime
)
go
insert into ##Table1 values ('Record 1','07/21/2003')
insert into ##Table1 values ('Record 2','07/22/2003')
insert into ##Table1 values ('Record 3','07/23/2003')
insert into ##Table1 values ('Record 4','07/24/2003')
insert into ##Table1 values ('Record 5','07/25/2003')
insert into ##Table1 values ('Record 6',
M*********e
发帖数: 190
36
来自主题: Database版 - 请教一个SQL Server的面试题
Don't know TSQL.
In Oracle, use rowid pseudocolumn.
思想就是先找到有discint col1的所有行(得到set 1)和有distict col2的所有行(得
到set 2)。取 set 1和 set 2中rowid相同的行.
不知道有没有漏洞。
#################
create table test(col1 varchar2(5), col2 varchar2(5));
insert into test values ('V1','B');
insert into test values ('V12','F');
insert into test values ('V3','F');
insert into test values ('V2','C');
insert into test values ('V2','D');
insert into test values ('V3','E');
#################
select * from test where rowid i... 阅读全帖
i*****w
发帖数: 75
37
Not sure if this is what you wanted, check the following query.
If you want to include future category names, then you need to use dynamic
SQL to get the distinct values in the category name column and then it will
pivot for you when you have new category name. For example, if you have a
new record with Category 4 and then Category 4 will be added to the result
grid.
declare @myTable table(id integer,category char(10),value float)
insert into @myTable values(1, 'category 1', 128)
insert into @my... 阅读全帖
r**********d
发帖数: 510
38
select @@version;
Microsoft SQL Server 2012 - 11.0.2218.0 (X64)
Jun 12 2012 13:05:25

Copyright (c) Microsoft Corporation
Enterprise Evaluation Edition (64-bit) on Windows NT 6.1 (Build
7601: Service Pack 1)
CREATE TABLE coolbid
(
ID INT UNIQUE
);
GO
INSERT INTO coolbid
VALUES (1),
(2),
(3);
GO
(3 row(s) affected)
INSERT INTO coolbid
VALUES (1);
GO
Msg 2627, Level 14, State 1, Line 2
Violation of UNIQUE KEY constraint 'UQ__coolbid__3214EC26654E5167'. Cannot
insert duplic... 阅读全帖
s*w
发帖数: 729
39
来自主题: Programming版 - how to destruct list with loop?
#include
using namespace std;
struct node {
int val;
node* next;
node(int v):val(v),next(NULL) {}
};
struct sll {
node* head;
sll():head(NULL) {}
~sll() {
cout << "sll destructing starts here" << endl;
node* p = head;
while(p) { // i am having problems destrucing here with looped list
node* todel = p;
p = p->next;
delete todel; // i thought delete make todel NULL so it breaks loop
todel = NULL; // does this help? nono... 阅读全帖
g****n
发帖数: 431
40
来自主题: JobHunting版 - Google onsite 5天后被拒了
看看这个办法行不行:
先把A和B两个字符串相同的prefix和suffix去掉,因为相同的前缀、后缀不影响答案。
然后需要做
的就是要么在A'的左端insert,右端delete;要么在A'的左端delete,右端insert。尝
试2次,就
可以得到解。
举例:
str B:ABCDE
case 1-
str A:ACDEF
去掉前后缀后,A'为:CDEF,B'为BCDE,比较可知在A'左端insert,右端delete即可。
case 2-
str A:BFCDE
去掉前后缀后,A'为:BF,B'为:AB,比较可知在A'左端insert,右端delete即可。
case 3-
str A:XABCE
去掉前后缀后,A'为:XABC,B'为:ABCD,比较可知在A'左端delete,右端insert即可。
大家看看有没有返利。

volunteered.
j*****g
发帖数: 223
41
总结一下面试的准备活动,希望有帮助.
==================== AREAS/TOPICS to study/prep/review ====================
复习的东西还挺多的。比不过刚毕业的呀 :), 脑子不好使了,东西也差不多忘光了...
嘿嘿....
• Sorting
o Bubble/select/insertion/counting/qsort/heap/merge/bst
o Time/space complexity analysis
• Caching design
o Replacement policy (LRU, LFU, NRU, etc…)
o Efficiency/complexity/performance
o Distributed cache
o Hashing
• Multi-thread
o Locking/mutex/semaphore/critical sec... 阅读全帖
j*****g
发帖数: 223
42
总结一下面试的准备活动,希望有帮助.
==================== AREAS/TOPICS to study/prep/review ====================
复习的东西还挺多的。比不过刚毕业的呀 :), 脑子不好使了,东西也差不多忘光了...
嘿嘿....
• Sorting
o Bubble/select/insertion/counting/qsort/heap/merge/bst
o Time/space complexity analysis
• Caching design
o Replacement policy (LRU, LFU, NRU, etc…)
o Efficiency/complexity/performance
o Distributed cache
o Hashing
• Multi-thread
o Locking/mutex/semaphore/critical sec... 阅读全帖
V*****i
发帖数: 92
43
来自主题: JobHunting版 - 问两道google题
There is no need to pass Dictionary and lookup table, use global variable or
use class. My solution as follows:
#include
#include
#include
#include
using namespace std;
// T(n) = \sum_{i=1}^{n-1} (T(i) * H(i+1))
const int MAXSIZE = 100;
class find_str {
private:
set dict;
int lookup_table[MAXSIZE];
public:
find_str(set &d) {
dict = d;
for (int i=0; i ... 阅读全帖
r******r
发帖数: 700
44
我当年的 homework,翻出来了。另一个 homework project, 帮我找到了第一个工作。
#ifndef LIST_H
#define LIST_H
#include
#include
#include
#include "node.h"
using namespace std;
/*=========================================================================*/
/**
* Implementation of a List ADT using a doubly-linked list.
*
* @version 1.0 2/25/05
*/
/*.........................................................................*/
/**
* Definition of exception handling class
*/
class ListEmpty : public ... 阅读全帖
s*****y
发帖数: 897
45
来自主题: JobHunting版 - 问道google面试题
写了一个基于tree的,插入的原则是
1.比较最高位的digit,大的插入右边,小于或者等于的插入左边
2.如果最高位相等,比较combine 2个数的结果,哪个大决定插入左边或者右边
所有node都插入到树的最低层。
建完tree后,traverse tree按照right, current left的顺序,测了一下案例,似乎是
对的,
//int A[] = {2, 3, 5, 78 }; //pass
//int A[] = {2, 3, 89, 897 }; //pass
// int A[] = {3,3,43}; //pass
int A[] = {9, 98, 987, 902, 399, 380}; //pass
//int A[] = {900, 9001, 2}; //pass
// int A[] = {2, 3, 89,94, 899 }; //pass
// int A[] = {2, 3, 89, 897 }; //pass
// int A[] = {2, 3, 5... 阅读全帖
a*****g
发帖数: 13
46
来自主题: JobHunting版 - facebook一题
c++ practice (use multiset):
#include
#include
using std::multiset;
using std::string;
int len_p = 4;
bool check_substr(string s, const multiset &L) {
multiset dup_L = L;
for (unsigned i=0; i string token = s.substr(i, len_p);
multiset::iterator itor = dup_L.find(token);
if (itor == dup_L.end()) {
return false;
}
dup_L.erase(itor);
}
return dup_L.empty();
}
int main(... 阅读全帖
a*****g
发帖数: 13
47
来自主题: JobHunting版 - facebook一题
c++ practice (use multiset):
#include
#include
using std::multiset;
using std::string;
int len_p = 4;
bool check_substr(string s, const multiset &L) {
multiset dup_L = L;
for (unsigned i=0; i string token = s.substr(i, len_p);
multiset::iterator itor = dup_L.find(token);
if (itor == dup_L.end()) {
return false;
}
dup_L.erase(itor);
}
return dup_L.empty();
}
int main(... 阅读全帖
w****x
发帖数: 2483
48
来自主题: JobHunting版 - 问一个facebook的电面
string digitMul(string str, int nDigit)
{
assert(nDigit >= 0 && nDigit <= 9);
int nCarrier = 0;
string strRes;
for (int i = str.size()-1; i >= 0; i--)
{
int nTmpDigit = str[i] - '0';
int nRes = nTmpDigit * nDigit;
nRes += nCarrier;
strRes.insert(strRes.begin(), ('0' + nRes%10));
nCarrier = nRes/10;
}
if (nCarrier > 0)
strRes.insert(strRes.begin(), ('0' + nCarrier));
return strRes;
}
string StrAdd(string str1, string ... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)