M***s 发帖数: 8769 | 1 买钥匙
http://www.ebay.com/itm/NEW-TOYOTA-TRANSPONDER-CHIP-UNCUT-IGNIT
program
Here is how to program the remote and transponder key. This will work on
some other Toyota models as well. In fact, the remote instructions were
taken from a Toyota Sienna web site. It took me a couple of tries to do this
, but it's not that hard. Just be careful and follow the instructions.
The key:
1. Simultaneously depress and release the brake and
accelerator pedals 1 time (one instruction kind of hints that you
shou... 阅读全帖 |
|
f*******n 发帖数: 696 | 2 Your first five single-quantity auction-style listings to be listed on the s
ite in a 30-day period have an insertion fee of $0.00 for eligible categorie
s.* (See insertion fees for more information.) These $0.00 insertion fee lis
tings also have a final value fee per listing of 8.75% or $20, whichever is
lower. Additional listings within the 30-day period and multi-quantity listi
ngs are subject to the following insertion fees and final value fees.
简单的说就是$25刀以下没区别,$25刀以上FVF从3.5% --> 8.75%(20刀封顶 |
|
o******h 发帖数: 1142 | 3 开了ebay basic store.
规定有◦Pay no insertion fees on up to 150 total FREE listings* per
month
如果我总的listing不超过150个。 如果全部list成good til canceled.
1. 是不是可以不用再管。30天之后,这些listing 也符合这个 150 free 的条件?
每个月都不会再被收入inserting fee? (感觉这样可以一劳永逸,又不担心被多收费。)
2. 还有这种good til cancelled是否也符合新的final value fee规定。就是最少4%那
种?
3. store自动的批量处理功能,能否很简单的把以前的30 days fixed listing, 重新
全部relist成good til cancelled?
You're charged one insertion fee per listing, per category, regardless of
the quantity of items, for any duration ... 阅读全帖 |
|
m*******i 发帖数: 370 | 4 thanks! 应该是这个。不知道怎么implement的
是使用array吗?比如
MyClass* obj_ptr=new MyClass[N];
根据hash key insert to the array, 然后maintain pointer根据insert 的顺序指向
上一个insert的obj和下一个将要insert的obj?
不知道是不是这样?给解释一下吧,多谢! |
|
i******s 发帖数: 301 | 5 你的解法应该是对的,基于这个写了如下C++代码
/*
* Author: Shengzhe Yao
* Date: 08 Nov 2010
*/
#include
#include
#include
#include
using namespace std;
// T(n) = \sum_{i=1}^{n-1} (T(i) * H(i+1))
int findAllStr(const set &dict, char *str,
int end, int *lookup_table) {
if (lookup_table[end] > 0)
return lookup_table[end];
int total = 0;
for (int i=1; i < end; ++i) {
char *substr = (str+i+1);
if (dict.find(substr) != dict.end()) {
char tmp =... 阅读全帖 |
|
i**********e 发帖数: 1145 | 6 Something to add.
>> Build a heap of N elements, ...
Please note that the N is a variable, not a constant. The N would grow as
more elements are being printed.
For example, to print the first element, N = 2, and you must insert 2^2 and
3^2 into the heap.
ExtractMin() would get you 2^2 as the first element to print. Then, you must
insert 2^3 to the heap next. There are now 2 elements in the heap, so N = 2
. ExtractMin() again and you get 2^3. Insert 2^4 to the heap. N is still 2.
ExtractMin() aga... 阅读全帖 |
|
w**s 发帖数: 141 | 7 我觉得就是就是把一颗树in order traverse 一遍,每得到一个node 就 insert 到另
一个tree里就行了把。 Tree Tranverse time complex is O(n). and insert into
one of the trees is in place. Code as below:
Suppose we have two trees, Tree A and Tree B. Let's merge Tree B into Tree
A.
void main(){
// visit every node of B and insert it into A
InorderTranverse(B);
}
void InorderTranverse(Node *root){
if (root == null), return;
InorderTranverse(root->left);
// get root and insert into the other Tree
InsertIntoBST(A, root->va... 阅读全帖 |
|
d*******d 发帖数: 2050 | 8 struct Node{
int v;
int count;
Node * left;
Node * right;
Node(int _v):v(_v), count(1), left(0), right(0){}
};
void insert(Node * & root, int v, int & c){
if( root == 0){
root = new Node(v);
return;
}
root->count++;
if( root->v == v){
if(root->right)
c = c + root->right->count;
}else if( v < root->v){
insert(root->left, v, c);
c = c + root->count - root->left->count;
}else{
insert(root->right, v, c);
}
return;
}
int find(int * a, int n){
... 阅读全帖 |
|
d*******d 发帖数: 2050 | 9 sigh,你这算什么,我前两天才郁闷呢,白板code,我写:
if ( myset.insert(XXX).second ){
blahblahblah;
}else{
blahblahblah;
}
结果人家没看懂,我解释了半天,人家说,"oh,我以为insert直接return iterator的".他
想的是先find()/count(),然后再insert什么的.
我只好跟他解释,你那样当然可以,不过find/count什么的hash了一次,后面insert又
hash了一次,效率低了,我这样一气呵成.
真的,我发现interview的时候,code不能写的太精妙了,对方真的可能一下看不懂的.我
碰到好几次了. |
|
z****u 发帖数: 104 | 10 字符串的 permutation 肯定是比较基础的题了,可是自己写了一下发现要 bug free
真心很难啊。调试了半天才 ok,而且程序看起来很臃肿,这要是在白板上铁定写不出
来啊
求大家指点一下该向哪个方向改进?
#include
#include
#include
char* insert(char* dst, int n, char c, int j)
{
/* Insert char c into string dst at location j */
n++;
dst = (char*) realloc(dst, sizeof(char) * n);
while(j < n)
{
char tmp = dst[j];
dst[j] = c;
c = tmp;
j++;
}
return dst;
}
char** permutation_recursive(char* s, int n, in... 阅读全帖 |
|
O******i 发帖数: 269 | 11 最近面了一家IT大公司被拒,一共经历了N轮技术面试。自己感觉还不算太坏,但也有
三轮发挥不太完美,所以心里很没底。
结果还是被拒了。
下面是这三轮的详细经历,请大家探讨一下大公司招人的标准。
第i轮是找二叉树从根开始的所有路径,使得该路径上所有节点的值之和等于一个给定
的数。我犯了一个战略错误,因为我在准备过程中看过CarrerCup的更通用的解法,不
要求从根开始,也不要求到叶子结束,于是我直接用了那个思路,在白板上写下了类似
下面的代码
void FindPath(Node* root, int sum, int path[], int level)
{
if (root == NULL)
return;
int s = 0;
for (int i = 0; i < level; i++)
s += path[i];
int value = root->data;
if (s + value == sum)
PrintPath(path, level, value);
path[leve... 阅读全帖 |
|
p*****2 发帖数: 21240 | 12 public void Add(Task task)
{
int i=0;
for(;i
{
if(task.deadline
{
list.Insert(i,task);
break;
}
}
if(i==list.Count)
list.Add(task);
}
public void Add(Task task)
{
if (list.Count == 0)
{
list.Add(task);
return;
}
int start = 0;
int end = list.Count - 1;
w... 阅读全帖 |
|
k***t 发帖数: 276 | 13 参照网上的思路写了一个。哪位大拿给Review一下。谢了。
我平时只写C,不用C++。所以可能有初级错误:)
#include
#include // HashMap
#include
using namespace std;
// cache entry
struct Entry {
int v; // dummy structure
};
class LRU {
private:
list > mlist;
unordered_map >::iterator> mht;
int cnt;
const static int MAX_SIZE = 10000;
public:
LRU () {cnt=0;}
~LRU () {}
void addEntry (string mURL, Entry mEntry) {
mlist.push_fron... 阅读全帖
|
|
O******i 发帖数: 269 | 14 我要是当时看过题目二就好了,哎...
题目一,我的面经,出处
http://www.mitbbs.com/article_t/JobHunting/32010769.html
有一个类,里头有两个Date对象
class T
{
Date date1;
Date date2;
}
其中Date是形如12/05/2011这样的日期,date1 <= date2,这样T就表示一个时间段。
假如有两个T类型的变量a,b,如果a和b代表的时间段之间没有gap, 也就是a和b
overlap, 则集合{a, b}是连续的。然后他解释扩展到多个时间段,什么情况下他们的
集合是连续的。
他的问题是,给你一个T类型变量的list,如何判断这个list是连续的还是不连续的。
我很快发现,每个Date在时间轴上是一个点,每个时间段T的变量是时间轴上的一条线
段,这题完全可以等同于
class Seg
{
int start;
int end;
}
其中 start <= end, 这样Seg就表示数轴上的线段。两条线段如果overlap,包括
overlap于一个点,则连续... 阅读全帖 |
|
P*A 发帖数: 189 | 15 来自主题: JobHunting版 - 讨论一道题 用BST挺好,比heap维护更方便,
修改了一下,可以不用把pair当作key来排序,在hash里面记录BST结点的指针
multimap bst;
hash_map > hm;
foreach given key k
0. if(hm.find(k)==hm.end()) {
hm.insert(make_pair(k, make_pair(1, bst.end())));
if (bst.size () < K) {
// bst里元素不足K
t = bst.insert (make_pair(f, k))
hm[k].second = t;
}
continue;
}
1. f = ++hm[k].first;
2. if (hm[k].second != bst.end()) {
// bst里有k了,那么更新freq值
bst.erase (hm[k].se... 阅读全帖 |
|
w****x 发帖数: 2483 | 16 //Multiple two strings "1234" * "23" = "28382"
//A Facebook phone interview problem, suppose to done within
//15 minutes, I believe is mission impossible. The solution below
//uses a common way to solve this problem, does not deal with the
//sign, the logic is still refined several times.
string Multiple(string str1, string str2)
{
assert(str1.size() > 0 && str2.size() > 0);
string strRes;
for (int i = str2.size() - 1; i >= 0; i--)
{
//Calculate digit multiple
int... 阅读全帖 |
|
p*g 发帖数: 141 | 17 private static String strMultiple(String s1, String s2) {
int len2 = s2.length();
String rv = "";
for (int i = 0; i < len2; i++) {
String part = strMultipleChar(s1, s2.charAt(i));
rv = rv + "0";
rv = strSum(part, rv);
}
return rv;
}
private static String strSum(String s1, String s2) {
StringBuilder sb = new StringBuilder();
int carryin = 0;
int len1 = s1.length();
int len2 = s2.len... 阅读全帖 |
|
m*****k 发帖数: 731 | 18 this will return the answer if the answer is there, but may return wrong
answer if the ansswer is not there, check this:
CREATE TABLE IF NOT EXISTS suppliers
(
sid TEXT ,
pid INTEGER
);
INSERT INTO suppliers VALUES ( '1', 2);
INSERT INTO suppliers VALUES ( '1', 3);
INSERT INTO suppliers VALUES ( '2', 2);
INSERT INTO suppliers VALUES ( '2', 4);
suppose x = '1'
you sql will return
2|1
but of coz 2 is not the ans.
while this following sql will return the right answer:
sel... 阅读全帖 |
|
h***i 发帖数: 1970 | 19 O(n*n)怎么也过不了large test?
void solve(vector> &board) {
int m = board.size();
if (m == 0) return;
int n = board[0].size();
unordered_set checked;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (board[i][j] == 'X') continue;
if (checked.find(i * n + j) != checked.end()) continue;
unordered_set s;
queue q;
s.insert(i * n + j);
... 阅读全帖 |
|
b*****u 发帖数: 648 | 20 来自主题: JobHunting版 - 一道设计题 用一个vector存储空闲日期段的开始
一个map 存储日期到演出的mapping
class calendar
{
vector available;
map dateToShow;
}
class performance
{
int date;
int program;
}
// assume that int binarySearch(vectorA, int x) returns the target
index i that A[i] <= x
// cost: log n
// return 0 if available, program id if not
int calendar::check(int date)
{
if (dateToShow.find(date)==dateToShow.end())
return 0;
else
return dateToShow[date];
}
// return true if successfully inserted
bool calendar::ins... 阅读全帖 |
|
b*****u 发帖数: 648 | 21 来自主题: JobHunting版 - 一道设计题 用一个vector存储空闲日期段的开始
一个map 存储日期到演出的mapping
class calendar
{
vector available;
map dateToShow;
}
class performance
{
int date;
int program;
}
// assume that int binarySearch(vectorA, int x) returns the target
index i that A[i] <= x
// cost: log n
// return 0 if available, program id if not
int calendar::check(int date)
{
if (dateToShow.find(date)==dateToShow.end())
return 0;
else
return dateToShow[date];
}
// return true if successfully inserted
bool calendar::ins... 阅读全帖 |
|
z****p 发帖数: 18 | 22
-The interval tree is a binary search tree where each node in the tree
stores a (key,value) pair: the key is the left end of an interval, and the
value is the right end.
-The interval tree for this problem is special in that the intervals are non
-overlapping.
-Initially, the tree only contain 1 node, the (1, MaxLong) pair.
-Check out value v: find the largest key that is smaller than v, look at its
value, assuming it looks like (k0,v0); if v0 is less than v, then v is not
in the pool, and the ... 阅读全帖 |
|
x***y 发帖数: 633 | 23 来自主题: JobHunting版 - 两道F的题 for 2nd problem, flip makes it possible to do insertion sort in O(nlogn)
time.
One nice thing about flip is that if we want to insert an element into an
ordered subarray in the head, it only takes O(logn) time.
For example, if we have an array 1 3 5 7 8 9 6 2 , and we want to insert 6
to 1
3 5 7 8 9.
First we need to know the expected position of 6(O(logn)) (assume that it's
k), then
flip(0) ---> 2 6 9 8 7 5 3 1 (0 is trivial)
flip(1) ---> 2 1 3 5 7 8 9 6 ( 1 = len(array) - ind(6)-1)
flip(4) -... 阅读全帖 |
|
h**o 发帖数: 548 | 24 没问题。
visited.insert(p) 就是在加。如果加的结果是真,说明本来没有的。
加的结果是假,说明已经有了。
“The first insert member function returns a pair whose bool component
returns true if an insertion was make and false if the hash_set already
contained an element whose key had an equivalent value in the ordering, and
whose iterator component returns the address where a new element was
inserted or where the element was already located.
” |
|
p****o 发帖数: 46 | 25 you can check output position for insert (tellp) and input position for
extraction (tellg).
string str = "abc xyz";
stringstream stream(str);
// tellp() returns 0; tellg returns 0;
cout << stream.str() <
stream >> str;
// extract: input moves from 0 to 3 (tellg() ==3), which is the
whitespace position
cout << str <
stream << str;
// insert: since no insertion so far, output position is still 0,
so it ... 阅读全帖 |
|
f**********t 发帖数: 1001 | 26 // BT(binary tree), want to find the LIS(largest independent set) of the BT
LIS: if the current node is in the set, then its children should not be in
the set. So that the set has the largest number of nodes.
vector MaxIndependentSet(TreeNode *r) {
if (!r) {
return vector();
}
static unordered_map> resultTable;
if (resultTable.find(r) != resultTable.end()) {
return resultTable[r];
} else {
vector vl, vll, vlr, vr, vrl, vrr;
if (r->l... 阅读全帖 |
|
l******6 发帖数: 340 | 27 3.
my 2 cents:
set f(n):
set ret
if n = 1
ret = {9}
else // assume set remove duplicate automatically
for int i = 1 : n - 1
for int fstNum in f(i)
for int sndNum in f(n - i)
ret.insert(fstNum + sndNum)
ret.insert(fstNum - sndNum)
ret.insert(fstNum * sndNum)
if sndNum!= 0
ret.insert fstNum/sndNum
cache {n , ret} for lookup
return ret
Finally find smallest positive not in f(9)
still can... 阅读全帖 |
|
f******h 发帖数: 45 | 28 也找工作了一段时间了,从版上学了很多,上周G家面完了,求个bless。
之前的一些都挂了,还在继续找其他的。等定下来之后一定发面经回报本版。
谢谢大家啦!!
1. http://www.mitbbs.com/article_t/JobHunting/32005597.html
1) Implement a simple calculator (+,-,*,/);
2) Implement "+1" for a large integer;
3) How to match Ads to users;
4) How to extract useful information from a forum webpage (list all
kinds of useful signal you can think of)
5) How to detect the duplicate HTML pages (large scale);
6) Find all the paths between two places on Google map;
7)... 阅读全帖 |
|
e**********6 发帖数: 78 | 29
确实是啊,我忘了。那就再多两个loop。一个是del,一个是insert,没有什么大不同。
核心想法就是穷举所有edit distance == 1的情况。我把之前的code删了,免得贻害众
人。。
如下:
// for delete.
for (int i = 0; i < curr.length(); i++)
{
curr.erase(i);
// compare and insert if in dict
}
// for insert
for (int i = 0; i <= curr.length(); i++)
{
for (char c = 'a'; c <= 'z'; c++)
{
curr = curr.substr(0, i) + c + curr.substr(i);
// compare and insert if in dict
}
} |
|
l******o 发帖数: 144 | 30 不用60行。43行我这个(没编译没跑没测,如果错误请见谅)
vector f(const vector& vs) {
map> edges;
unordered_set out_vertices;
for (size_t i = 0; i + 1 < vs.size(); i++) {
const auto& s1 = vs[i];
const auto& s2 = vs[i + 1];
size_t j;
for (j = 0; j < s1.size() && j < s2.size(); j++) {
if (s1[j] != s2[j]) {
edges[s1[j]].insert(s2[j]);
break;
}
}
if (j == s2.size() && j < s1.size()) throw runtime_error();
for (char c ... 阅读全帖 |
|
w********0 发帖数: 377 | 31 这时当时的code,我copy下来了。请大牛指点。
Given a nested list of positive integers: {{1,1},2,{1,1}}
Compute the reverse depth sum of a nested list meaning the reverse depth of
each node (ie, 1 for leafs, 2 for parents of leafs, 3 for parents of parents
of leafs, etc.) times the value of that node. so the RDS of {{1,1},2,{1,1}
} would be 8 = 1*1 + 1*1 + 2*2 + 1*1 + 1*1.
{1,{4,{6}}}
6*1 + 4*2 + 1*3 = 6+8+3 = 17
struct Iterm
{
int v;
bool isInteger();
int getInteger();
list getList();
l... 阅读全帖 |
|
a*****2 发帖数: 96 | 32 求最大的s[i]:
//就用二叉树就足够了吧,树的节点里记录比本节点小的个数
public int sln(){
BSTNode root = new BSTNode(a[n-1],0)
int result = 0;
for i in n-2:0{
//O(logn)
result = max(result,insert(root ,a[i],0));
}
return result;
}
class BSTNode{
int value;
int descendants;
BSTNode left = null;
BSTNode right = null;
}
public int insert(BSTNode root, int value, int cnt){
if(root == null)
return 0;
int result = 0;
if(root.value < value){
result += root.descendants+1;
... 阅读全帖 |
|
|
|
M*********8 发帖数: 15312 | 35 1. Oral B advantage toothbrush $2
-$2 insert 4-3 P&G OR $2 eq
Final price = Free
2. Olay 2 pack soap $2.19
-$2 insert 4-3 P&G OR $2 eq
Final price = .19
如果店里允许eq stack with 纸q,那就恭喜你了
3. money maker
airwrik twin pack warmer 49¢(buy 4 save $4后的价格)
-$1/1 Air Wick Warmer(coupons.com)X4
=-2.01
4. Comet cleaner $1.09
-.25 IP (coupons.com) tripled
Final price = .34
5.Yakisoba方便面 .99
-.50 insert 3-13 SS doubled
Final price = FREE
6. Dial hand soap $1
-.35 insert 3-13 RP tripled
Final price = Free
7. si... 阅读全帖 |
|
m********r 发帖数: 2862 | 36 贡献下周cvs的几样东西,能滚ecb还能小赚一笔,如果有off的话就更好啦!
权当抛砖引玉,大家讨论下哈!
注意:有很多人反应说4off的胖子是给24ct的,我看了下,我的胖子说any 1 zyrtec,小字说是
除了trial sizes的,大家仔细查看下再用。
前段时间有要这个sample的里面有个free的coupon,那就更爽啦!
另外:chris00 说在cvs的coupon机上刷到4off的crt,大家去买的时候可以试试
倒赚2/4刀Zyrtec (5 ct), $5.99
Get $5.99 Extra Care Bucks when you buy 1 (limit 1)
$4/1 Zyrtec Product 4/10/2011 RP Insert (exp 7/31/2011)
网上打印的2 off coupon:https://www.zyrtec.com/offers
免费的Motrin PM (20 ct), $4
水银mm说有的店有2off的coupon可以找到
Get $3 Extra Care Bucks when you buy 1 (limit 3)... 阅读全帖 |
|
G*8 发帖数: 13261 | 37 - Buy 1 Gain Laundry Detergent + 2 Additional Gain Products
(Safeway is running a buy 3 save 3 promotion on the Gain til 8/23)
- Receive $3 白条. (Starts 8/19)
SD说16号就拿到白条了。最好19号再买,没有白条还可以要到。
http://thefrugalfind.com/the-safeway-3-gain-catalina-is-printin
Buy 1 Gain Liquid Detergent, 32 Load $4.99
Buy 2 Gain Dish Soap $0.99
Use (1) $1/1 Gain Detergent 8/14/2011 RP Insert (exp 9/30/2011)
Use (2) $0.50/1 Gain Dishwashing Liquids 8/14/2011 RP Insert (exp 9/30/2011)
Pay: $4.97, receive $3.00 Catalina
... 阅读全帖 |
|
d**e 发帖数: 2420 | 38 用到了coupon今天报纸有,或者网上打印。
http://coupons2.smartsource.com/smartsource/index.jsp?Link=Q4ND
Pepsico Get $5 eb wyb $15 Limit 1:
Lipton Iced tea 16.9 oz 12 pk, Amp 16 oz 4 pk, or Frappuccino 9.5 oz 4 pk $5
-$2 off 2 Lipton 12 packs (exp 10/22/11) PepsiCo insert 10/02/11
-$2 off 2 Starbucks Frappuccino or Double Shot 4pks (exp 10/22/11)
PepsiCo insert 10/02/11
Cheetos or Fritos 8.5-10.5 oz $3
-$1 off 2 Cheetos/Fritos 8.5oz+ (exp 10/22/11) PepsiCo insert 10/02/
11Gatorade 20 oz 4 ... 阅读全帖 |
|
p****u 发帖数: 22764 | 39 原文链接:
http://blog.wired2fish.com/blog/bid/63566/Five-for-5-Five-Bass-
Every-Angler-Should-Know
Learn five ways to rig bass fishing plastics to catch bass in any situaiton
We've had a bunch of requests to do a piece on how to tie several rigs for
bass fishing with soft plastics and when and where to fish them. We'll start
with this overview piece with diagrams on how to rig the plastics. We'll
follow up with underwater videos to show how the rigs look in the water and
we'll expand on these rigs w... 阅读全帖 |
|
c*******s 发帖数: 5839 | 40 guide frame一般是金属,热胀冷缩比insert显著,上的又紧,
insert有点瑕疵就会勒碎
insert材料的热胀冷缩率很小,接近陶瓷。
夏天的时候遇到过insert掉出去的问题,估计也是这个原因 |
|
b****i 发帖数: 805 | 41 $0.00 insertion fees (auction-style listings)
The first 5 auction-style listings that you list on the site in a 30-day
period are eligible for $0.00 insertion fees. The 30-day period starts with
your first eligible listing. You'll have 4 more opportunities to list with $
0.00 insertion fees during those 30 days. After the 30 days pass, the next
30-day period starts with your next listing that's eligible for $0.00
insertion fees.
Only auction-style listings are eligible.
Listing upgrade fees stil |
|
j*******7 发帖数: 6300 | 42 Why We Know Our Universe, And Everything In It, Had A Beginning (Free Bible
Insert)
My career as a Cold Case Detective was built on being evidentially certain
about the suspects I brought to trial. There are times when my certainty was
established and confirmed by the cumulative and diverse nature of the
evidence. Let me give you an example. It’s great when a witness sees the
crime and identifies the suspect, but it’s even better if we have DNA
evidence placing the suspect at the scene. If the b... 阅读全帖 |
|
Y**u 发帖数: 5466 | 43 ☆─────────────────────────────────────☆
TrueStory (不是幸福的坑不挖) 于 (Fri Oct 14 11:10:12 2011, 美东) 提到:
This talk is about the chemical, Dopamine, that people feel in ecstasy.
http://www.youtube.com/watch?v=axrywDP9Ii0
It makes people want, without even knowing what is to be wanted. It is a
major chemical that people show in infatuation or new relationships. The
speaker also mentions its similar effect in some people's religious
pursuit.
When this chemical fades, the rosy glasses fall, and then t... 阅读全帖 |
|
x*****o 发帖数: 28 | 44 exactly!!!
all the insertion happen in the middle.
But because I also need to access the array frequently.
Any good suggestions?
The access pattern is random, while the insertion or deletion is sequential
within one cycle. (means, e.g. I insert 4th, delete 8th, insert 10th....)
I just thinking of implementing a special class based on array to
handle it...
Previously I don't take a serious consideration on this issue, I just use the
vector, and the performance gains is just ok.
and this noon, I h |
|
f*****e 发帖数: 5177 | 45 I run SQL query estimated execution plan again one query.
The plan showed that the cost of "delete" and "insert" is 900%.
What does that mean?
PS: Which one of the following queries is better?
Query1:
if exist (select * from table1 where ...)
begin
update table1 set ...
end
else
begin
insert into table1 ...
end
Query2:
if exist (select * from table1 where ...)
begin
delete from table1 where ...
end
insert into table1 ...
Query3:
delete from table1 where ...
insert into table1 ... |
|
B*****g 发帖数: 34098 | 46 I guess is because most of insert blob, it is insert an empty_blob() first,
then update the column to real value. so insert trigger fired when the value
is empty_blob(). But when you try
INSERT INTO table
SELECT *
FROM table
the trigger works. |
|
B*****g 发帖数: 34098 | 47 ORACLE
CREATE TABLE BEIJING_TEMP
(
ID NUMBER(10),
VALUE VARCHAR2(100),
PARENTID NUMBER(10)
);
ALTER TABLE BEIJING_TEMP ADD (
CONSTRAINT BEIJING_TEMP_PK
PRIMARY KEY
(ID));
Insert into BEIJING_TEMP
(ID, VALUE, PARENTID)
Values
(8, 'e', 7);
Insert into BEIJING_TEMP
(ID, VALUE, PARENTID)
Values
(7, 's', 6);
Insert into BEIJING_TEMP
(ID, VALUE, PARENTID)
Values
(6, 'a', 5);
Insert into BEIJING_TEMP
(ID, VALUE, PARENTID)
Values
(5, 'b', 4);
Inser |
|
i****a 发帖数: 36252 | 48 found this example. can do calculation from the sub query
CREATE TABLE Sales (DayCount smallint, Sales money)
CREATE CLUSTERED INDEX ndx_DayCount ON Sales(DayCount)
go
INSERT Sales VALUES (1,120)
INSERT Sales VALUES (2,60)
INSERT Sales VALUES (3,125)
INSERT Sales VALUES (4,40)
select *
from Sales
SELECT DayCount,
Sales,
coalesce((SELECT Sales
FROM Sales b
WHERE b.DayCount = a.DayCount+1), 0)
AS NextDaySales
FROM S |
|
b*f 发帖数: 3154 | 49 这么一个例子:
IF OBJECT_ID('T1') IS NOT NULL
DROP TABLE T1;
GO
CREATE TABLE T1 (id int PRIMARY KEY, timestamp);
GO
INSERT INTO T1(id) VALUES (1);
GO
declare @v timestamp;
INSERT INTO T1(id) OUTPUT inserted.timestamp as v VALUES (10);
select @v
假设这个@v是俺想作为stored-procedure的OUT参数返回,怎样才能把inserted.
timestamp值传递给@v呢?
多谢,给俺解决问题的奉上双黄包一个... |
|
b**********a 发帖数: 25 | 50 @@IDENTITY returns the most recently created identity for your current
connection, not necessarily the identity for the recently added row in a
table. You could have a situation where there is a trigger that inserts a
new record in a Logs Table, for example, when your Stored Procedure or
INSERT SQL Statement inserts a record in the Orders Table. If you use @@
IDENTITY to retrieve the identity of the new order, you will actually get
the identity of the record added into the Log Table and not th... 阅读全帖 |
|