w*******s 发帖数: 96 | 1 If the string is not the same length, my code will crash because of array
index out of boundary. Can you help find the bug?
//Refer Algorithm 4th, page 722
void exch(string &a, string &b)
{
string c = a;
a = b;
b = c;
}
int compare(int a, int b)
{
if (a
if (a==b) return 0;
if (a>b) return 1;
}
void ThreeWayQsort(vector &v, int low, int high, int d)
{
if (high<=low) return;
//3 way partition to handle duplicate
int lt = low;
int gt = h... 阅读全帖 |
|
p*****2 发帖数: 21240 | 2 QuickSort
static void QuickSort(int[] arr, int start, int end)
{
int pivot=arr[(start+end)/2];
int l=start;
int r=end;
while(l
{
while(arr[l]
l++;
while(arr[r]>pivot)
r--;
if(l<=r)
{
int tmp=arr[l];
arr[l]=arr[r];
arr[r]=tmp;
l++;
r--;
}
... 阅读全帖 |
|
K*****k 发帖数: 430 | 3 典型的Hoare双向扫描Partition法一般都会在左右设置sentinel, 或者对左右边界检测
下标越界,这个非典型的代码却不用。
int Partition(int arr[], int left, int right)
{
int pivot = arr[left + (right - left) / 2];
while (left <= right)
{
while (arr[left] < pivot]
left++;
while (arr[right] > pivot]
right--;
if (left <= right)
{
swap(arr, left, right);
left++;
right--;
}
}
return left;
} |
|
t***t 发帖数: 6066 | 4 说我的解法,看如何。
1. 找到pivot点。pivot点就是最接近key的node.
2. 保持俩指针,一个从pivot往前走一个往后走。
3. 每次每个指针看下一步,哪个abs(node.data-Key)小,那个指针前进一步。
4. 记住总步数,到了m步就停。
总时间复杂度log(n)+m
|
|
x*********w 发帖数: 533 | 5 螺母那题是不是这样的
每次两个partition, 先以第一个螺母为基准partition螺钉,在partition螺钉的过程
中可以找到pivot和第一个螺母match的螺钉(归到pivot位置上去)
然后以找出的这个pivot螺钉为准partition螺母。
很想了一段时间啊 |
|
k*****5 发帖数: 25 | 6 思路类似于寻找Kth smallest element in an array, median of X*Y个数也是寻找X*Y
/2th smallest element. 选一个数,把它叫做pivot, 用pivot 来partition 所有机器
上的数,并统计有多少个数小于等于pivot, 根据这个信息缩小查找的范围 (divide
and conquer)。
extra |
|
b********6 发帖数: 97 | 7 那我也贴个java的好了
public ListNode insertionSortList(ListNode head) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
if (head == null) return null;
ListNode dummy = new ListNode(-1);
dummy.next = head;
ListNode i = head;
while (i.next != null) {
int n = i.next.val;
ListNode j = dummy;
while (j!=i&&j.next.val < n){
... 阅读全帖 |
|
l*********8 发帖数: 4642 | 8 c/c++ 可以写成这样。
void partition(int * low, int * high, int pivot) {
for (int *p = low; p < high; ) {
if (*p == pivot)
++p;
else if (*p < pivot)
swap(*low++, *p++);
else
swap(*p, *--high);
}
} |
|
r*******k 发帖数: 1423 | 9 从头便利word
两两从头开始比较
abandon
abase
可以确认n在s前面, n-->s
这样遍历所有词之后,可以得到很多对关系
综合起来就是所有词序了
综合可以用类似quicksort
每次选一个pivot,就分成了2份
当然,划分会漏下很多
这时再选pivot,就会添加进一些新的
算法直到每个点都选作pivot之后,
应该就能得到一个确定的顺序
当然,还有要考虑的是
字典里 A和a的排序
空在前在后
比如
abandon
abandoned
可能还有数字
如果abandon和abandoned之间,有一个
abandonal,
我不知道这个词该排哪里。。。 |
|
P**********k 发帖数: 1629 | 10 不太明白,能否展开说说
我感觉大概的意思是类似quick sort.
先从red jug里面选择一个r1,然后用这个r1作为pivot把blue jugs分成两部分,一部
分set1包含所有比r1小的jug,另一部分set2包含所有比r1大的jug
然后从red jug里面再选择一个r2,这次先和之前的r1比较,这样就可以确定,只需要
在set1或者set2中搜索,
可是我的问题是,如果要是代码实现的话,是不是需要一个类似于binary tree的结构
来存储之前的pivot list,这样每次可以对于新的red jug,先在这个pivot list里面
搜索,来确定要partition的interval。。。
有做过这个的xdjm能来讨论一下么 |
|
z****e 发帖数: 54598 | 11 emc所谓的软件远不如它们的下属子公司vmware靠谱
vmware做应用软件远不如它买的那个搞spring的interface21靠谱
后来interface21被收购后成为vmware的spring division
现在emc把interface21改名字改location了,弄到湾区去叫pivotal
我感觉emc是硬件公司,后来买了vmware
vmware是搞系统软件的,后来买了rod johnson那个interface21
现在叫pivotal,也就是pivotal才是真正的写那些应用软件的人
那个做vert.x的tim fox以前就在spring division |
|
w*****t 发帖数: 485 | 12 用三数取中法简单些,最坏有O(N^2)的可能性,但非常低:
int SelectPivot(vector &a, int low, int high)
{
// 三数取中法
assert(low >= 0);
if (low >= high) return low;
int mid = low + (high - low) / 2;
if (a[low] < a[mid]) swap(a[low], a[mid]);
if (a[mid] < a[high]) swap(a[mid], a[high]);
if (a[low] < a[mid]) swap(a[low], a[mid]);
// hide pivot
// |--low--| ... |--pivot--|--high--|
swap(a[mid], a[high-1]);
return high - 1;
}
pivot |
|
b******n 发帖数: 851 | 13 smallest k, using partition
int[] topKSmallest(int[] arr, int k) {
if (k <= arr.length) return arr;
helper(arr, 0, arr.length-1, k);
return arr.copyOfRange(0, k+1);
}
void helper (int[] arr, int start, int end, int k) {
if (start>=end) return;
int partitionIdx = partition(arr, start, end);
int leftLen = partitionIdx-start+1;
if (leftLen == k) return;
else if (leftLen > k) helper(arr, start, partitionidx, k);
else helper(arr, partitionIdx+1... 阅读全帖 |
|
c*********i 发帖数: 46 | 14 int findKthLargest(vector& nums, int k) {
return findKth(nums, k, 0, nums.size()-1);
}
int findKth(vector& nums, int k, int start, int end)
{
if(start==end)
return nums[start];
int pos = partition(nums, start, end);
int size = pos-start+1;
if(k==size)
return nums[pos];
else if(k>size)
return findKth(nums, k-size, pos+1, end);
else
return findKth(nums, k, start, po... 阅读全帖 |
|
G*******n 发帖数: 2041 | 15 刚开始自己写,调了半天没搞出来,后来仔细对照书上的code,发现有两个细微区别。
但是不解为什么必须要这么做,请大侠指教。
两个细微差别是在partition里:
int Partition3(int *a, int left, int right)
{
int pivot = a[(left + right) / 2];
while (left < right) //leetcode: while (left <= right)
{
while (a[left] < pivot)
{
left++;
}
while (a[right] > pivot)
{
right--;
}
if (left < right) //leetcode: if (left <= right)
{
int temp = a[left];
a[le... 阅读全帖 |
|
a*****g 发帖数: 19398 | 16 你用的是 pivot report 么?
如果不是用的这个,或者不知道什么是 pivot report,
那就更不知道什么是 pivot report 里面的 filter 功能了
我提出的 bug 躲在这个地方呢。 |
|
t******l 发帖数: 10908 | 17 如果假设你题目的意思是 order does matter, 5,2,1 和 1,2,5 是不同的三份分法。
那这个其实用我前面的不允许出现零的情况的 pivoting modelling 就行了 (
imaginary seat 的概念)。具体这么说:
八块 pizza 排成一排,任意相邻两块 pizza 之间形成一个 imaginary seat。总共 7
个 imaginary seat。index 成 1 到 7。
然后把两个 pivot (屏风) assign 在 imaginary seat 上,不允许坐同一个 seat。
以上等效为从 imaginary seat index set {1 .. 7 } 里,choose 2 index, put
pivot there. (2 out of 7 combination wo/ repetition)。
所以是 C(7, 2) = 7*6/2 = 21 种。 |
|
r*m 发帖数: 16380 | 18 SHORT-TERM: TWO RELIABLE TOP SIGNALS TRIGGERED, BULLS BETTER TAKE SOME
PROFITS
今天有两个top signals触发了,考虑到在10/15 Market Recap里提到的the first
possible pivot date around 10/21 to 10/22,因此真有可能今天就是top了。我知道
,这么说可能大部分人都不会相信,我也不敢相信,不过,根据6.5.2c Week
Seasonality Watch,下周很多半是red week,所以牛牛在这里take some profits,可
能不会有大错吧,特别是follow SPY ST Model的,因为这个model is designed to
stay in a trend as long as possible,因此是没有take partial profit的信号的,
要自己找机会,我觉得现在应该是时候了。
0.0.2 Combined Intermediate-term Trading Signals, 3 point val... 阅读全帖 |
|
r*******u 发帖数: 143 | 19 Stock Research Trader
My holdings NUAN, INVN, ALXN ,VPHM ,SPPI all with 7 percent stop
Sprewell Yu
Week ending: 01/14/2012
READING THE MARKET
It’s another week of constructive action for the market. The first two trading day of the week has seen institutional buying as the volume exceeded prior days
for two sessions, this is a sign of big boy getting back to the market, and
also the indexes were able closed in the high of trading session which stays
above the 200 and 50 day moving average line.... 阅读全帖 |
|
|
|
a******1 发帖数: 176 | 22 Just did a pivot table. Pivot table function is different than the one from
Original excel, so the layout is different.
Guys, let me know if there is a better way you all want to see the pivot
table.
Thanks, |
|
p*********e 发帖数: 32207 | 23 一般来说大家都明确,就是如果要持球突破,那一定要先放球再抬中枢脚
这里要抠的,就是“放球”二字
FIBA official rule目前最新版本是2008,里面pivot定义的部分,对上面规定如此说:
(原始链接:http://www.fiba.com/asp_scripts/downMana.asp?fileID=1037)
25.2.2 Progressing with the ball for a player who has established a pivot
foot while
having the control of a live ball on the playing court:
While standing with both feet on the floor:
. To start a dribble, the pivot foot may not be lifted before the ball is
released from the hand(s).
这里这个“release”看来就是“放球”的原始出处
那么到底啥算release呢?
releas |
|
b*******r 发帖数: 6655 | 24 又复习一遍全文, 好象如此, 就是说跑动中, 可以多跨一步, 也就是我理解的慢三步上
篮. 但是NCAA
A player who catches the ball while moving or dribbling may stop
and establish a pivot foot as follows:
b. When one foot is on the playing court:
1. That foot shall be the pivot foot when the other foot touches in
a step;
2. The player may jump off that foot and simultaneously land on
both; neither foot can then be the pivot foot.
这个第一条恐怕不一样吧?
completion
either |
|
b*******r 发帖数: 6655 | 25 FIBA
Establishing a pivot foot for a player who catches a live ball
on the playing court:
While standing with both feet on the floor:
The moment one foot is lifted, the other foot becomes the pivot foot.
While moving
If one foot is touching floor, the foot becomes the pivot foot
这就是我从小理解的走步规则, 从小也听说NBA可以多走一步, 今天才算明白 |
|
p*********e 发帖数: 32207 | 26 因为他跨第一步前已经处于持球状态
也就是说他跨第一步已经是pivot了,第二步其实就是lift pivot foot
那样的话,规则规定如果要pass or shoot,你必须在pivot foot再落地前完成pass或者
shoot |
|
p*********e 发帖数: 32207 | 27 对于这个,nba的规定其实是要比fiba宽松的
nba的规定是你持球后可以迈两步,然后第一步的脚抬起来再落地前球出手(传或者投就
可以)
fiba是如果你接球时有一只脚在地上,那么那个脚就要是中枢脚
但如果你在空中接球的话,则落下来的第一只脚是中枢脚
(上面的都是针对行进间接球直接上篮的相关规则)
换句话说nba里面你不管是不是空中接球(开始持球时双脚离地)都可以迈两步上篮
fiba你想接球后两步则必须空中接球
问题是
lebron这个,你仔细看一下录像,他gain control之后右脚已经先落地了
也就是说右脚这时候是pivot foot
紧接着他左脚迈到三分线外,这是合法pivot
紧接着他右脚跟着往三分线外迈,按规则pivot foot再次触地前他必须pass或shoot
但实际上他是这个脚落定到三分线外才投的 |
|
H*******o 发帖数: 504 | 28 if both feet are on the ground when one catches the ball, either foot can be
the pivot foot. let's say I choose the left foot by lifting the right foot,
then I can't lift the left foot unless I jump off the left foot to shoot or
pass. In Lebron's case, he lifted his pivot foot, put it down, then shoot
the ball. So he traveled when he put his pivot foot down.
ff course you can dribble after you catch the ball. that's a totally different scenario.
sorry can't input chinese here. |
|
p*********e 发帖数: 32207 | 29 "
c. In starting a dribble after (1) receiving the ball while standing still
, or (2) coming to a
legal stop, the ball must be out of the player’s hand before the pivot foot
is raised off the
floor.
d. If a player, with the ball in his possession, raises his pivot foot off
the floor, he must
pass or shoot before his pivot foot returns to the floor. If he drops the
ball while in the air, he
may not be the first to touch the ball.
"
你看一下d |
|
p*********e 发帖数: 32207 | 30 fiba下也是好球:
"
25.2.2 Progressing with the ball for a player who has established a pivot
foot while having the control of a live ball on the playing court:
While standing with both feet on the floor:
. To start a dribble, the pivot foot may not be lifted before the ball is
released from the hand(s).
. To pass or shoot for a field goal, the player may jump off a pivot foot
, but
neither foot may be returned to the floor before the ball is released from
the
hand(s).
" |
|
p*********e 发帖数: 32207 | 31 再发一个ncaa的规则,这个说的比较明确:
"
Art. 4. After coming to a stop and establishing the pivot foot:
a. The pivot foot may be lifted, but not returned to the playing court,
before
the ball is released on a pass or try for goal;
86 RULE 4 / DEFINITIONS
b. The pivot foot shall not be lifted before the ball is released to start
a
dribble.
" |
|
p*********e 发帖数: 32207 | 32 问题是如果jump off a pivot foot可以理解为pivot foot抬起的起跳呢?
这样你的这个例子就是违例
但抬起pivot foot后另一脚起跳然后在任何一只脚落地前出手是合法的 |
|
p*********y 发帖数: 2288 | 33 确定了pivot foot之后,另一只脚站定,pivot foot离地绝对算走步
不然的话,非pivot foot就在地上曾来曾去,也不离地的平移好了,嘿嘿 |
|
p*********e 发帖数: 32207 | 34 晕
你这个动作属于pivoting,必须有pivot foot时才可以做
规则规定是凡是在pivoting相关规则允许以外的动作都是违例,
也就是说这是一个允许列表
而不是禁止列表
换句话说你这个规则没提到的动作就属于违例 |
|
s*******u 发帖数: 1855 | 35 我的理解:
以前:跳步一概不合法.travel.
该规则以后:第一步跳步可以,可以用任何一只脚做pivot,然后再单脚迈一步,然后pivot
落地前出手.
但是,不能够第二步跳步.这样无论怎么说,pivot脚再次落地了.
不知道我这个理解对不对.马龙等专家,普及一下?谢谢! |
|
s*******u 发帖数: 1855 | 36 这个Malone说的比较清楚.应该ok.
但是,我还是不明白,我觉得nba规则有自相矛盾.
比如这个跳步.第一步单脚迈(好象是左脚,假定是左脚吧),那么左脚就几经确定了pivot
foot了.然后第二步跳的时候,左脚也升空了,也就是pivot lift了.这个时候再双脚着
地,岂不是pivot foot先lift再land,without shoot or pass?
这个跳步规则跟总的travel规则矛盾啊? |
|
p******r 发帖数: 257 | 37 规则这些年一直是这样吗?颠覆人生观了啊这。。。
以前一直都是觉得确定pivot foot之后,要想传球或投篮,pivot foot应该是人最后离
开地面的东西,否则就是走步,然后觉得上篮是特例。
要是这样的话,比如说,右脚pivot,左脚乱点半天,突然左脚踩定,右腿抬起来个转
身勾手啥的,这是个很bug的move啊 |
|
p******r 发帖数: 257 | 38 吼吼,那看来fiba规则还是不许抬pivot然后另一只脚触地啊
我是查的ncaa的(网上随便找最先找到的)
Section 70. Art 4. a
After coming to a stop and establishing the pivot foot:The pivot foot may
be lifted, but not returned to the playing court, before
the ball is released on a pass or try for goal;
它这个还是没管另一只脚,这个还是2010-11年的呢http://www.ncaapublications.com/productdownloads/BR11.pdf
but |
|
p******r 发帖数: 257 | 39 我先前一直的理解是,一旦pivot foot确定了以后,不管投篮还是传球,这只脚一定是
最后离开地面的(或者pivot foot单脚跳,或者双脚起跳,不能只抬pivot foot,另一
条腿还在地上),要不然就是走步
看来是我一直sb了? |
|
g****t 发帖数: 31659 | 40 只有在end dribble之后才能使用pivot规则的吧?
如果是dribble中间,两次球触地之间,你可以多次脚落地的.
所以问题其实是什么是end dribble.
sorry, I made a mistake, let me correct myself
catch the ball, then land with left, your left is pivot foot, you can land
your right foot and shoot before you land your left foot again.
If you catch the ball with left foot on the ground, your left foot become
pivot, and you can only land your right and shoot before landing the left
again.
如果我双手持球的时候,是在空中呢? 然后双脚落地了.
这种情况下,蹦步是没问题的.
... 阅读全帖 |
|
u****h 发帖数: 2193 | 41 这个其实不标准,不过NBA一般不吹了。
“左脚在地上右脚跨步开始上篮”,这个动作说明左脚是pivot foot。走步的规则是如
果pivot foot抬起,在其放下之前必须出手。你说的最后的“以左脚起跳”其实是
pivot foot已经第二次落地了,这个就构成走步。
不过again,这种走步球无论是谁都经常打出来,NBA很少吹。 |
|
h**n 发帖数: 981 | 42
In the video:
Point of emphasis:
To shoot for a field goal pivot foot may be lifted but may not be returned
to the floor before the ball is released from the hand(s).
NBA rule book:
Section XIII - Traveling:
d. If a player, with the ball in his possession, raises his pivot foot off
the floor, he must pass or shoot before his pivot foot returns to the floor.
If he drops the ball while in the air, he may not be the first to touch the
ball. |
|
a*****e 发帖数: 329 | 43 是的,都是先确定pivot foot之后,然后用另外一只脚起跳,Pivot foot离地,出手投
篮,Pivot foot落地之前,球离开手,就是好球。不管你有没有停顿! |
|
a*****r 发帖数: 1272 | 44 很好的录像,涨知识了。
FIBA规则是Pivot脚落地前球必须出手,而没有规定是不是Pivot脚起跳。上面的录像就
是非pivot脚起跳,果然够风骚,没有走步。 |
|
m*****r 发帖数: 1240 | 45 There is no rule against the mere lifting of your pivot foot (or indeed any
foot in any situation). A traveling violation can only possibly be committed
when a lifted foot touches the floor again. Example: Say you dribble and
complete a dribble.Nov 6, 2014
rules - When can you lift your pivot foot and go for a shot ...
sports.stackexchange.com/.../when-can-you-lift-your-pivot-foot-and-go-for... |
|
s*****c 发帖数: 753 | 46 While I believe it is a travel (in FIBA and NCAA), I also know NBA is very
loose in this. Referee will think he is still haven't gain control of the
ball.
See NBA's rule book:
b. A player who receives the ball while he is progressing or upon completion
of a dribble, may take two steps in coming to a stop, passing or shooting
the ball. A player who receives the ball while he is progressing must
release the ball to start his dribble before his second step.
The first step occurs when a foot, or ... 阅读全帖 |
|
m*****r 发帖数: 1240 | 47 我仔细看了一下。如果图中第一行最后已经双手触球,其实也要分两种情况。
1. 左脚未落地就双手触球 (也就是第一行倒数第二张就已经双手触球)。
情况1之下,触球后,左脚落地,右脚落地,左脚再落地。 毫无疑问,用了3
steps, 走步
2. 如果是左脚落地之后(或者同时)(也就是第一行倒数第二张时没有双手触球,但
是倒数第一张时双手触球了)
情况2之下,根据nba的规则 ‘A player who receives the ball while in
progress or upon completing his dribble is allowed a one-two count after
gathering the ball’ 。 抠字眼的话, 左脚落地发生在 before/at the same time
of completing dribble but definitely not ''after''. 所以到了图片第二行的右脚
左脚才是 one-two count。
情况2有很多例子:很多哈登的‘euro step’(比吉诺比利多一步);
下面链接里的欧... 阅读全帖 |
|
P*****s 发帖数: 263 | 48 等高手来指点,我瞎掰几句。说得不好的地方,请大家一起指正讨论。
1。姿势。从录像看,除了后倾以外,我觉得主要是posture太僵硬,就是关节僵硬,膝
关节,腰等。膝关节不够灵活。蹲下,挺胸。跟高手学习,就在眼前。见这个贴里的
fly和密西根州大的儿子Peter,观察他们的膝关节。小孩学习滑雪快不光是重心低,而且也是他们的关节灵活。
http://www.mitbbs.com/article_t2/Ski/31236071.html
2。平衡 balance。姿势正确以后,就是掌握重心在二脚之间变来变去。滑雪这点跟滑
冰有相似之处。edge control。你可以练习用一只脚,见录像里fly,左右做蛇形滑行
。这是power skating里的一个基本动作。还可以练习foward backward pivoting。就
是滑冰里向前滑的时候,突然转身向后滑。或者反之,向后突然转身向前。一只脚
pivoting(花样滑冰)或者二只脚pivoting(冰球)。学习向后滑可以改进backseat
driving,因为后滑身体要前倾才行。等到前后左右单双脚都灵活自如了,就容易了。
:)
3。上下... 阅读全帖 |
|
O****e 发帖数: 3290 | 49 窄的道要用小回转, still carving with some pivot but no skid.
在 kinecty (kinecty) 的大作中提到: 】
果宽度不够,没有空间完成半个圆的话,这样几个turn下来速度就会加起来了。是不是
这样?
flatten skis,再把重心转移到downhill,engage downhill的edges,然后千万不要
pivot,follow the skis就行了。
一定的speed才能平稳而且迅速的完成这个过程。我觉得适应高速,为的就是这个。
要pivot和skid?我看一些video,好像过fall line的时候,总是会扫出很多雪。 |
|
r********7 发帖数: 229 | 50 上面的解释都非常全了。这里看到一个关于pivot的video,说不定有用?
http://www.youtube.com/watch?
v=gikhnEOqGrw&list=FLSfSi3GQ99yjE0uudHExGCg&index=1&feature=
plpp_video
我也和胖海绵一样,很少用到pivot。我觉得pivot就是为了过门,或者是减速
吧? |
|