- _aaron
- Jul 24, 2007
-
The underscore is silent.
|
DIW posted:Here's a brute force approach in Python.
I did that one like this:
code:upper = sum(A)
lower = 0
for i in range(len(A)):
upper -= A[i]
if upper == lower:
return i
lower -= A[i]
return -1
|
#
¿
Feb 9, 2011 04:39
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 2, 2024 10:59
|
|
- _aaron
- Jul 24, 2007
-
The underscore is silent.
|
DIW posted:
Seems to break on large lists. This should give equilibrium at i=50000
That's because there was a typo! lower -= A[i] should have been lower += A[i]
code:def equi(A):
upper = sum(A)
lower = 0
for i in range(len(A)):
upper -= A[i]
if upper == lower:
return i
lower += A[i]
return -1
I just tested with the same list you used, and it seems to work fine if I use the correct code
|
#
¿
Feb 9, 2011 06:19
|
|
- _aaron
- Jul 24, 2007
-
The underscore is silent.
|
Otto Skorzeny posted:
... in which case any raise they give you is really an advance against future raises - they're going to pull the same shenanigans again.
This isn't really true. Lots of companies (especially bigger ones) give out raises as a percentage each year. If you get a bigger raise one year, that factors into all future years. (e.g., If you would typically get a 5% raise each year, and this year you get a 10% raise due to a counter-offer, all of you future 5% raises are actually bigger than they would have been.)
|
#
¿
Jul 29, 2011 04:47
|
|
- _aaron
- Jul 24, 2007
-
The underscore is silent.
|
MachinTrucChose posted:
I'm a fresh grad. I had an interview today, where everything went really well, but...
It's definitely raising the sorts of flags you guys warn about, but it will help my career more than staying at home would.
Where did you live, and how's the job market there? If you want to program, that's definitely a position I'd avoid. However, if there's nothing else available, you're probably right in that it's a better career move than staying at home or doing something completely unrelated to programming.
|
#
¿
Aug 10, 2011 01:06
|
|