由买买提看人间百态

topics

全部话题 - 话题: sum
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
w*****e
发帖数: 806
1
来自主题: Statistics版 - a question about sum() and array
TOTAL=SUM(OF SCORE{1}-- SCORE{14})会有用吗??
~~~用2个- 代替1个-
D******n
发帖数: 2836
2
来自主题: Statistics版 - a question about sum() and array
%macro test;
data a2;
set a1;
array score (14) abc--dde;
total = sum(of
%do i=1 %to 14;
score(&i)
%end;
);
run;
%mend;
%test
A****t
发帖数: 141
3
来自主题: Statistics版 - a question about sum() and array
total=sum(of score{*});
D******n
发帖数: 2836
4
这个离一个命令也只差了一点了。。。lol
y=runif(100);
y=c(y,1-sum(y));
lol
s*r
发帖数: 2757
5
一旦有sum up to N这个条件,这些数字就不是iid了,can be negative correlated.
a***r
发帖数: 420
6
呵呵,放了个假,半个月没干活了,有点找不到感觉^_^
可是这是什么??咋没看懂哩(⊙o⊙)
我写的是
A <-runif(n,0,100)
A <-A/sum(A)
B******y
发帖数: 9065
7
scale任意一个常数都可以,但scale以Sum就破坏了Independence。
k*******a
发帖数: 772
8
来自主题: Statistics版 - 再请教一个R的用法 SUM(Yi-mean)^2
sum((y-mean(y))^2)
t***r
发帖数: 157
9
how to find the distribution of the sum of discrete and continuous uniform variable
x~uniform(0,1)
y discrete uniform 0 with p, 1 with probability 1-p
how to find the distribution of x+y?
thanks
n**********e
发帖数: 18
10
测一个continuous variable对event发生率的影响,
用了Wilcoxon rank sum test结果给出p-value 0.02显示有影响
再用logistic regression结果给出p-value 0.42
这两结果也相差太远了吧!到底哪个test更准呢?
谢谢牛人指导!
z******n
发帖数: 397
11
没想明白Wilcoxon rank sum test在这里是怎么用的
s*r
发帖数: 2757
12
Wilcoxon rank sum test shows the distribution of the x variable is different
by a location shift in y=1 group and y=0 group
logistic regression shows there is no significant linear increasing of logit
(pr(y)) as each unit increase of x
z******n
发帖数: 397
13
有趣,设想这样一个例子:
在变量x轴上有如下y的0-1排列:
x --0--1--0--1--0--1--0--1--0--1--
貌似logistic reg不显著,而wilcoxon rank sum显著
没有验证过

different
logit
k********g
发帖数: 56
14
来自主题: Statistics版 - weighted sum of independent bernoulli
有一列独立但是不同分布的bernoulli variables
想知道他们的weighted sum 是什么分布,weight 都是正的。
不知道各位谁知道这方面的结果,假设这些Weight满足一些性质也可以。
我现在唯一知道的结果就是,如果weight 都是1, 那是一个 poisson-binomial 分布
另外问一下各位有谁知道一个 continuous version of poisson distribution。
就是一个连续变量,但是pdf形状像poisson.
谢谢
J******m
发帖数: 97
15
来自主题: Statistics版 - ask a sum function
I'm looking for a function that will sum a variable across all
observations by identifier.
For example, if I have
ID ID_2 ID_3 A
1 2 6 1
1 2 6 0
2 3 8 2
2 3 8 2
My expect results
ID ID_2 ID_3 A
1 2 6 1
2 3 8 2
thanks a lot!
p******p
发帖数: 13
16
来自主题: Statistics版 - ask a sum function
data a;
input id id_2 id_3 payment;
cards;
1 2 6 1
1 2 6 0
2 3 8 2
2 3 8 2
;
run;
proc sql;
select distinct id, id_2, id_3,sum(payment) as payment from a group by
id, id_2, id_3;
quit;
k*******a
发帖数: 772
17
来自主题: Statistics版 - ask a sum function
If you use R, use dplyr library
library(dplyr)
group_by(data, ID, ID_2, ID_3) %>% summarise(A = sum(A))
Z********6
发帖数: 10
18
来自主题: Statistics版 - ask a sum function
proc summary data=a nway missing;
class id id_2 id_3;
var payment;
output out=pay_s(drop=_type_ _freq_) sum=;
run;
output:
Obs id id_2 id_3 payment
1 1 2 6 1
2 2 3 8 4
If there are more variables for summary, just add them to the VAR statement.
w******w
发帖数: 136
19
来自主题: Maryland版 - 求推荐 好的dim sum馆子
汉宫 at Rosslyn, VA
Ping Pong Dim Sum at Dupont Circle, DC
怡东楼 at Silver Spring, MD.
k********n
发帖数: 18523
20
来自主题: Stock版 - [合集] PCLN
☆─────────────────────────────────────☆
kbrhouston (石油工人-一切MM都是普赛,纸老虎) 于 (Sat Nov 5 22:33:29 2011, 美东) 提到:
1来便于查阅
2来便于老牛清水(怕误删)
3便于顶进十大,壮大声势,繁荣古板
4减少肥猫工作(否则他需要花精力查看大家的所有请求贴)
谢谢大家
☆─────────────────────────────────────☆
MB80528 (肥猫(Contrarian)[食MM而肥]) 于 (Mon Nov 7 23:08:16 2011, 美东) 提到:
要最新预测的,
请在此报名股票符号。
打算提供20到30个预测。
由最先报名的股票符号开始。
☆─────────────────────────────────────☆
fockugcd (fockugcd) 于 (Mon Nov 7 23:09:47 2011, 美东) 提到:
胖肥猫,是不是永久免费的:)???????????????

☆────────────────────... 阅读全帖
f**d
发帖数: 768
21
来自主题: 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: ... 阅读全帖
x*******5
发帖数: 152
22
来自主题: JobHunting版 - 问一道programming peals上的题
终于有人做pearl,给一个我的解答
此题是第9题的扩展,第9题求的是subvector whose sum is close to zero,解答如下
(python)
def Subvector_Zero(v):
"find the subvector whose sum is close to zero"
s=[0 for a in range(len(v))]
s[0]=v[0]
for i in range(1,len(v)):
s[i]=v[i]+s[i-1]

s=sorted(s)
minv=sys.maxint
for i in range(1,len(v)):
minv=min(minv,s[i]-s[i-1])
return minv
C++:
/*Description: find the subvector whose sum is close to zero
Input: vector t
Output: int
K.O.: auxil... 阅读全帖
o*q
发帖数: 630
23
来自主题: JobHunting版 - 请教leetcode高频题是哪些题
# Title Editorial Acceptance Difficulty Frequency
1
Two Sum 28.3% Easy
292
Nim Game 54.4% Easy
344
Reverse String 57.3% Easy
136
Single Number 52.2% Easy
2
Add Two Numbers 25.6% Medium
371
Sum of Two Integers 51.6% Easy
4
Median of Two Sorted Arrays
20.4% Hard
6
ZigZag Conversion 25.6% Easy
13
Roman to Integer 42.7% Easy
237
... 阅读全帖
UD
发帖数: 182
24
来自主题: JobHunting版 - one amazon interview problem
below code seems to work, and should be O(n) time and O(1) space, if you disagree, please list your argument.
The idea behind is the use and resue of sum(i,j), that's why the O(1) space.
sum(i,j)=sum of all the 1s between i and j.
sub-seq(i,j) has equal 1s and 0s when sum(i,j)*2=j-i+1, we start by setting i=0,j=A.length-1, then searching from both ends.
1. if sum(i,j)*2==j-i+1, then found it
2. else if sum(i,j)*2>j-i+1, we have more 1s then 0s, then we check A[i] and A[j]:
a. if A[i]==A[j], t... 阅读全帖
m********6
发帖数: 58
25
来自主题: JobHunting版 - 攒人品发Google onsite面经
Session 4:
A valid number may not contain 2,3,4,5,7. Flip those numbers 180 degrees and
it's not a valid number. Single digit numbers is a special case. It
contains 0, 1, 8. For 2N digit numbers, the first digit can be 1,6,8,9 and
the next N-1 digits can be 0,1,6,8,9. For 2N+1 digit numbers, you can insert
0,1,8 in the middle of any valid 2N digit numbers and it's still a valid
number.
1 digit: 3
2N digit: 4 * 5 ^ (N-1)
2N+1 digit: 3 * 4 * 5 ^ (N-1)
For example, there are 20 valid 4 d... 阅读全帖
k****r
发帖数: 807
26
来自主题: JobHunting版 - 简单的题自己绕糊涂了 求解答
为什么sort by base_area呢?可不可以按A1sort然后dp呢?我试着练一下。create一
个class作为dp的内容including last X2 and current sumH
class dp {
int x2;
int sum;
}
public maxHeight(square[] s) {
sortSquareByA1(s); //sort by A1
int len = s.length;
int[][] dp = new int[len][s.len];
int result;
dp[0][0].sum = square[0].H;
dp[0][0].x2 = square[0].x2;
for(int i = 1; i < len; i++) { //add one more
if (square[i].A2 > square[i - 1].A2) {
dp[i][0].sum = dp[i - 1][0].sum + square[... 阅读全帖
m******u
发帖数: 12400
27
def sum_of_fraction(N, D):

sum = []

sum.append (N[0])
sum.append (D[0])
for i in range(1, len(N)):
sum[0] = sum[0] * D[i] + sum[1] * N[i]
sum[1] = sum[1] * D[i]
m = min(sum)
for j in range(2,m):
if sum[0] % j ==0 and sum[1] % j == 0:
sum[0] = sum[0] / j
sum[1] = sum[1] / j
return sum
N = [2, 3, 56, 43, 23, 5, 6, 94, 27, 54]
D = [43, 23, 45, 45, 56 ,38, 102, 45, 21, 76]
print(sum_of_fraction(N,D))
N ... 阅读全帖
i****d
发帖数: 35
28
来自主题: JobHunting版 - 刚电面完,分享两个题目
借助sum数组
sum[i] = SUM{ a[i] | i = 0~i}
1. i= 0~n-1,计算sum[i]的同时,利用hash_map,以sum[i]为key,记录下sum[i] 和
i的值。这样遇到相同的就说明sum[i] == sum[j], j conflit。O(n)
2. 1)还是计算sum[i]。O(n)
2) 排序,排的时候以sum[i]为key,同时带上下标i。第3)步有用。O(nlgn).
3) 遍历排序后的sum[i]。创建数组min_index,min_index[i] 是 比sum[i]小的元
素中的最小的下标。通过一个临时变量记录并更新这个下标,遍历一遍就可以建立min_
index数组了。 O(n)
4) i = 0~n-1, 对于每个i, 在排序好的sum[i]数组中找 sum[j] 正好 <= sum[i]-
k。那么以a[i]为终点的满足条件的subarray最长的长度就是 i-min_index[i]。通过一
个临时变量max记录并更新这个长度,遍历完就可以知道最大长度了。
总体可以到O(nl... 阅读全帖
m******m
发帖数: 19
29
来自主题: JobHunting版 - 刚电面完,分享两个题目

借助sum数组
sum[i] = SUM{ a[i] | i = 0~i}
1. i= 0~n-1,计算sum[i]的同时,利用hash_map,以sum[i]为key,记录下sum[i] 和
i的值。这样遇到相同的就说明sum[i] == sum[j], j conflit。O(n)
2. 1)还是计算sum[i]。O(n)
2) 排序,排的时候以sum[i]为key,同时带上下标i。第3)步有用。O(nlgn).
3) 遍历排序后的sum[i]。创建数组min_index,min_index[i] 是 比sum[i]小的元
素中的最小的下标。通过一个临时变量记录并更新这个下标,遍历一遍就可以建立min_
index数组了。 O(n)
4) i = 0~n-1, 对于每个i, 在排序好的sum[i]数组中找 sum[j] 正好 <= sum[i]-
k。那么以a[i]为终点的满足条件的subarray最长的长度就是 i-min_index[i]。通过一
... 阅读全帖
g***s
发帖数: 3811
30
来自主题: JobHunting版 - 问两道数字题
we can preProcess using DP to save time;
time is O(logN×logN)
public class MaxSum {
private static final int MAX_DIGIT = 7;
static int dp[][] = new int[MAX_DIGIT+1][MAX_DIGIT*9+1];
public static int findMax(int x){
int digits = ("" + x).length();
int max = 0;
int t;
for (int sum = 0 ; sum <= 9*digits ; sum++){
max = Math.max(max, t = totalWaysUpto(x, sum));
}
return max;
}
private static int totalWaysUpt... 阅读全帖
f*********m
发帖数: 726
31
Print All Combinations of a Number as a Sum of Candidate Numbers
http://www.leetcode.com/2010/09/print-all-combinations-of-number-as-sum.html
原文如下,稍作修改(把target 从7该为9):
“To search for all combination, we use a backtracking algorithm. Here, we
use the above example of candidate={2,3,6,7} and target=9.
First, we start with a sum of 0. Then, we iterate over all possibilities
that can be added to sum, which yields the possible set of sum={2,3,6,7}.
Assume now that sum=2, we continue adding all poss... 阅读全帖
j*****y
发帖数: 1071
32
来自主题: JobHunting版 - A家intern 面经,求祝福
bless
int total_day(int day, int month, int year)
{
int sum = 0;
sum += (year - 1) * 365 + (year - 1) / 4;
switch(month)
{
case 1:
break;
case 2:
sum += 31;
break;
case 3:
sum += 31 + 28;
break;
case 4:
sum += 31 * 2 + 28;
break;
... 阅读全帖

发帖数: 1
33
来自主题: JobHunting版 - Leetcode 689居然是fb的高频题?
叔这个题目是动态编程。
其实不是很复杂。
1. 就是你先算一下以k为长度,滑动窗口的和,放到一个数组里。
2. 从左到右计算 以i为起点,到i为止,最大值的窗口的起始index
比如说[1,3,2,0]
所对应[0,1,1] 因为 2 + 0 < 3 + 2
3.从右向左计算以z为为起点,从z向右考虑,最大窗口和的起始index
4.因为窗口不能重复,所以i + k <= j + k <= z
在j的范围内遍历并且更新结果就可以了。
代码如下:
class Solution {
public int[] maxSumOfThreeSubarrays(int[] nums, int k) {
int sum = 0, len = nums.length - k + 1;
int[] sums = new int[len];
for (int i = 0; i < nums.length; i++) {
sum += nums[i];
if (i >= k) sum -= nums[i... 阅读全帖
S******t
发帖数: 151
34
来自主题: JobHunting版 - 问两道fb题
我贴一个第一题能通过的代码吧:
vector bestA;
int bestLen;
void search(int idx, int sum, int len, vector>>& f,
vector& ret, vector& A) {
//cout << idx << " " << sum << " " << len << endl;
if (idx == 0) {
int lenA = bestA.size();
vector v = ret;
/*
for (int i = 0; i < v.size(); i++)
cout << v[i] << " ";
cout << endl;
*/
if (v.size() < lenA || lenA == 0) {
bestA = v;
return;
... 阅读全帖
S**I
发帖数: 15689
35
来自主题: JobHunting版 - [合集] 问个google面试题
☆─────────────────────────────────────☆
Bayesian1 (Jason) 于 (Tue Jun 21 01:52:31 2011, 美东) 提到:
Given a binary tree, find 2 leaf nodes say X and Y such that F(X,Y) is
maximum where F(X,Y) = sum of nodes in the path from root to X + sum of
nodes in the path from root to Y - sum of nodes in the common path from root
to first common ancestor of the Nodes X and Y
☆─────────────────────────────────────☆
SecretVest (Secret Vest) 于 (Tue Jun 21 04:01:30 2011, 美东) 提到:
not hard if someone is used... 阅读全帖
r*******g
发帖数: 1335
36
来自主题: JobHunting版 - 问两道fb题
第一题其实是写一个函数
possible(int index, int sum, int sz)
从index开始,是否存在sz的subset,和为sum。由于sz只可能是从1到N,对每个sz,用
上面函数计算对应的sum是否存在。
假设总和为N
(SUM-sum)/(N-sz)=sum/sz,所以如果sz一定,那么sum也就一定。
btw: 下面程序是抄的
bool possible(int index, int sum, int sz) {
if (sz == 0) return (sum == 0);
if (index >= total_size) return false;
if (dp[index][sum][sz] == false) return false;
if (sum >= original[index]) {
res.push_back(original[index]);
if (possible(index + 1, sum - original[index], sz - 1))
... 阅读全帖
j****a
发帖数: 12
37
来自主题: JobHunting版 - 请教一道 Google 面试题
//不才献丑了
sum[0]=0,buf[0]=0,i=0;
P1(i){
i++;
buf[i]=buf[i-1];
sum[i]=sum[i-1]+1;
return sum[i];
}
p234(i){
i+=3;
buf[i]=sum[i-3];
sum[i]=sum[i-3];
return sum[i];
}
p4(i){
i+=1;
buf[i]=buf[i-1];
sum[i]=sum[i-1]+buf[i-1];
return sum[i];
}
sum[i]=max{p1(i-1),p234(i-3),p4(i-1)};
M=sum[n];
//有不好之处,请不吝赐教
j****a
发帖数: 12
38
来自主题: JobHunting版 - 请教一道 Google 面试题
//不才献丑了
sum[0]=0,buf[0]=0,i=0;
P1(i){
i++;
buf[i]=buf[i-1];
sum[i]=sum[i-1]+1;
return sum[i];
}
p234(i){
i+=3;
buf[i]=sum[i-3];
sum[i]=sum[i-3];
return sum[i];
}
p4(i){
i+=1;
buf[i]=buf[i-1];
sum[i]=sum[i-1]+buf[i-1];
return sum[i];
}
sum[i]=max{p1(i-1),p234(i-3),p4(i-1)};
M=sum[n];
//有不好之处,请不吝赐教
g**********y
发帖数: 14569
39
来自主题: JobHunting版 - 问两道数字题
第一个,brutal force:
public class MaxSum {
public int findMax(int x) {
int digits = ("" + x).length();
int max = 0;
for (int sum = 0; sum <= digits*9; sum++) {
max = Math.max(max, totalWaysUpto(x, sum));
}
return max;
}

private int totalWaysUpto(int x, int sum) {
if (sum < 0) return 0;
char[] c = ("" + x).toCharArray();
int N = c.length;
int count = 0;
if (N == 1) return sum<=x? 1 : 0;
... 阅读全帖
d****n
发帖数: 233
40
来自主题: JobHunting版 - 请教亚麻一道onsite面试题
I'm wondering if the following works.
long maxSumNonOverlap(Record[] records) {

long[] sums = new long[records.length + 1];
long max = 0;
sums[0] = 0;
Arrays.sort(records, new Comparator() {
@Override
public int compare(Record o1, Record o2) {
int diff = o1.end - o2.end;
return diff == 0? o1.start - o2.start : diff;
}});

int i = 0;
for(; i < reco... 阅读全帖
d****n
发帖数: 233
41
来自主题: JobHunting版 - 请教亚麻一道onsite面试题
I'm wondering if the following works.
long maxSumNonOverlap(Record[] records) {

long[] sums = new long[records.length + 1];
long max = 0;
sums[0] = 0;
Arrays.sort(records, new Comparator() {
@Override
public int compare(Record o1, Record o2) {
int diff = o1.end - o2.end;
return diff == 0? o1.start - o2.start : diff;
}});

int i = 0;
for(; i < reco... 阅读全帖
i******d
发帖数: 61
42
来自主题: JobHunting版 - FB电面面经
hm.continsKey()里面的东西和hm.put()里面的东西应该符合下面等式
sum[i] - sum[j] = target //sum[j]是put进去的, sum[i]是后来判断contains的
你的相当于 sum[i] + target = sum[j] + target 所以不对
如果put了(sum[i]+target). 后面就要判断 hm.containsKey(sum[i])
或者可以
put(sum[i]), 后面判断hm.containsKey(sum[i]-target)
if(hm.containsKey(sum[i]+target)){
int j = hm.get(sum[i]+target);
if(j return true;
}

... 阅读全帖
i******d
发帖数: 61
43
来自主题: JobHunting版 - FB电面面经
hm.continsKey()里面的东西和hm.put()里面的东西应该符合下面等式
sum[i] - sum[j] = target //sum[j]是put进去的, sum[i]是后来判断contains的
你的相当于 sum[i] + target = sum[j] + target 所以不对
如果put了(sum[i]+target). 后面就要判断 hm.containsKey(sum[i])
或者可以
put(sum[i]), 后面判断hm.containsKey(sum[i]-target)
if(hm.containsKey(sum[i]+target)){
int j = hm.get(sum[i]+target);
if(j return true;
}

... 阅读全帖
p****h
发帖数: 3
44
来自主题: Computation版 - [转载] 级数求和问题,急呀!

It converges. Because: lim(Tn+1 / Tn) -> a < 1.
To sum, you got to factorize like a^n*b^2 + 2*b*c*n*a^n+c^2*n^2*a^n
Sum(a^n*b^2)=b^2*a/(1-a)
Sum(2*b*c*n*a^n) = 2*b*c*Sum(n*a^n)
Sum(c^2*n^2*a^n) = c^2*Sum(n^2*a^n)
You now got to solve Sum(n*a^n) and Sum(n^2*a^n) separately.
Sum(n*a^n)*a - Sum(n*a^n)= a*(2a-1)/(1-a), so:
Sum(n*a^n) = a*(1-2a)/(1-a)^2
Use same logic to work out Sum(n^2*a^n) and then sum.
s**x
发帖数: 7506
45
来自主题: JobHunting版 - 问一道题(7)
found this
http://www.dsalgo.com/2013/03/longest-subarray-with-equal-numbe
Longest subarray with equal number of ones and zeros
Problem
You are given an array of 1's and 0's only. Find the longest subarray which
contains equal number of 1's and 0's.
Solution
We will keep a running sum of "no of ones minus no of zeros" for each index
of the array. For any two indices, if the running sum is equal, that means
there are equal number of ones and zeros between these two indices. We will
store the runn... 阅读全帖
f******h
发帖数: 45
46
也找工作了一段时间了,从版上学了很多,上周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)... 阅读全帖
r****y
发帖数: 26819
47
来自主题: LeisureTime版 - 鬼故事
重新考虑一下,sum说能确定product不能判断以后,他们都知道的事实是:
(1)和为奇数,(2)和不是两个质数之和,(3)和必然小于55(如果和大于等于55,
则其中一个数可以是质数53,而2X53>100,则两数可判断)。满足这三个条件的奇数有
:11,17,23,27,29,35,37,41,47,51,53。从前两句对话中,product和sum都
已知:和必然在11个数中。
接下来,我们首先排除不可能的和,这是站在sum的角度做。sum根据他已知的和,推理:
如果对一个和A,存在两种拆分方式A=B+C=D+E,而BxC和DxE的其它所有可能的
因子组合方式MxN都不能使得M+N属于这11个奇数,那么product就能确定两数,而sum却
无法在最后判断他拿到的是B+C还是D+E。那么这个和就不可能。
简单特例情况是,如果和有两种方式写成2的幂加上一个质数,则sum无法在最后一句对
话说他能确定两数。例如,sum拿到和51,因为product可能拿到4x47或者8x43,这两种
情况下product都能确定两数,但sum没法在最后判断他拿到的是4+47还是8+43。以此排
除... 阅读全帖
i****d
发帖数: 35
48
来自主题: JobHunting版 - 刚电面完,分享两个题目
基本思路是这样:
既然要求subarray的sum>=k,也就是说,要找 max {j-i | sum[i+1...j]>=k}
所以就遍历i,找同时满足这俩条件的j
1. sum[i+1...j]>=k。如果对sum数组排序了,就可以binary search找sum[j]<=sum[i]
-k就可以了
2. 满足第一个条件的下标j里面,我们要挑个最小的(下标)。因为已经对sum数组排序
了,假设我们找到了 *刚好* 满足第一个条件的j, 那么在排序好的sum数组中,在
sum[j]之前的都也满足第一个条件 (已经排序了。。。)
所以动机就是,我们为每个排序好的sum[j],维持一个在sum[j]之前的最小下标就可以了
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)