由买买提看人间百态

topics

全部话题 - 话题: iend
(共0页)
y*******o
发帖数: 6632
1
来自主题: JobHunting版 - jump game II solved in 1 loop(Q(n))
1 loop method:
class Solution {
public:
int jump(int A[], int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(n<=1){
return 0;
}
int iend=A[0];
int stepCount=1;
int nextEnd=A[0];

int i=1;
while(i if(iend return -1;
}
while(i<=iend){
if(nextEnd阅读全帖
p**o
发帖数: 3409
2
来自主题: JobHunting版 - Reverse Words in a String
The idiomatic way:
In [1]: s = 'the sky is blue'
In [2]: ' '.join(reversed(s.split()))
Out[2]: 'blue is sky the'
Follow-up: OK, looks simple, but `s.split()` creates auxiliary space.
Can you do it in-place, i.e., with O(1) space?
为了迎合这样的变态要求,我们被迫要写下面这样C风格的所谓“算法”代码
In [9]: def swap_chars(s, iBgn, iEnd):
...: """ Reverse chars in buffer s ranging from iBgn to iEnd (
exclusive).
...: """
...: for i in range(iBgn, (iBgn+iEnd)//2):
...: j = iBgn + iEnd - i - 1
.... 阅读全帖
L***s
发帖数: 1148
3
来自主题: JobHunting版 - reverse words in a string
# non-idiomatic python code
# just to illustrate the algorithm clearer
def swap_chars(s, iBgn, iEnd):
""" Reverse chars in buffer s ranging from iBgn to iEnd (exclusive).
"""
for i in range(iBgn, (iBgn+iEnd)//2):
j = iBgn + iEnd - i - 1
s[i], s[j] = s[j], s[i]
def reverse_words_inplace(s):
""" Reverse all words in a sentence in-place.
E.g. 'this is simple' -> 'simple is this'
"""
n = len(s)
# First pass, char-level reversal in the sentence
... 阅读全帖
a******n
发帖数: 164
4
来自主题: JobHunting版 - 一道面试题
I also think circular buffer would be a solution:
struct DataSet
{
int nNumberOfEntries;
int iStart;
int iEnd;
uint32_t uKey;
Msg msgSet[MAX_NUMBER]; //MAX_NUMBER can be calculated
//by using max msg rate
float fpTotalSum;
};
void AddMessage(Msg *pMsg)
{
pMsg->m_nKey = uKey++;
memcpy(msgSet + iEnd++, pMsg, sizeof(Msg));

fpTotalSum += pMsg->value;
//check the head of the buffer, to make iStart
//points to Msg that it's still valid,
//and
i*********8
发帖数: 3229
5
三哥不都是傻子
To my fellow Indians, do we think westerners are our real friends? They like
us because we are indecisive, due to our govt model. They need not fear us
like they fear China. Because China can achieve whatever it desires, they ha
ve the means and the power.
Look who supported us when these western nations were hell bent on criticizi
ng us - Pakistan, Sri Lanka, China, Bangladesh. When will we learn that a fr
iend in neighborhood is better than thousands far away? If only we could com
e to
k******t
发帖数: 1498
6
来自主题: StartUp版 - 如何让vc出钱而不控制公司
确实原型和产品差距相当大,我以前对此就认识不足。Kickstart最早是做indy music的
,后来技术创新项目比如各种3D打印机逐渐占了主流。如果产品的潜在受众面窄,基本
上没什么希望从kickstart筹到足够的钱。
我不确定你是做什么的,通常情况下解决办法无非就是:1)找外部投资,VC,family fr
iends fools etc;2)找合作伙伴,如生产商供应商,先期支付少部分资金让别人能活
,属于降低硬性资本需求;3)减少产品功能,做minimum sellable product,投资随着
功能的减少相应也会减少,但是对潜在顾客的吸引力也可能会变小。
无论哪一种解决办法,都不容易,这也是很多显而易见的需求不能被满足的原因。
un
发帖数: 1311
7
来自主题: Singapore版 - 这文章写得非常好
I don't understand why she made herself so miserable :P
they can definitely afford a better rental apt, according to my seaturtle fr
iend in SH.
n******e
发帖数: 89
8
来自主题: NewYork版 - JFK长期停车怎么样最便宜?
If you have a friend living in CT, or Long Island, you can ask for airport p
ick up and park your car near your friend's place for free. If you have a fr
iend in NYC except Manhattan, it is also possible to finding a street that o
nly has once per week streeting cleaning and you can ask your friend to move
your car, also for free.
v******a
发帖数: 45075
9
小老乡,哥就跟你说三点
1. 你没必要跟任何人解释你做任何事的原因,特别是网上的。解释个屁,丫们爱咋想咋
想。你不少一块肉。
2. 欠朋友的钱要还上。在国外能借钱给你的朋友都应该是 a friend in need is a fr
iend indeed. 为了几百,千把小钱失去这样的朋友,不值。欠信用卡的钱, 如果你不
回美国,不打算在美国发展下去,forget about it. 那些占着道德制高点的装逼犯的屁
话你就当个屁,嗨,要不叫屁话呢。
3. 我欣赏你的冒险精神,但冒险不等于鲁莽。你要走的地方都不太平。要尽量做好基本
功课,避免墨西哥的情况再现。
希望你早日横扫南美,非洲。
R*o
发帖数: 3781
10
by Dave Hunt
Not A Question Of Obligation
Such rationalization simply won't work. Of course Calvinism's God prevents t
he non-elect from coming to Him. He very clearly does so by withholding the
grace without which they can't believe.
Furthermore, He has predestined them to eternal damnation. Could there be an
y stronger means of preventing the nonelect from coming to Him? What this fr
iend apparently means is that God withholds nothing that He is under obligat
ion to bestow.
Obviously God is un... 阅读全帖
(共0页)