langadi cloud provider kenekge interview ekakata giya. mata okkoma interview 7k thibba. godakma ahuwe linux prashna
- a software was deployed to a compute instance last week and it worked fine. It no longer works. you see a memory error. how would you debug this
- what's LD_PRELOAD
- `/tmp` in linux has the sticky bit on. why
- question on how http works in terms of networking
- scaling horizontally/vertically
- system design question was on designing a monitoring system
- some basic live coding for about 1.5hrs across 3 interviews
Ironman wants to travel from Avengers tower to stark tower. on the way, he has to make stops and rest (he has fought extraterrestrials and is weak). on every stop there is either charging device for his suit or he needs to vanquish a stray alien consuming his power. charging devices increase the suit power and fighting the alien drains it. if any given time his power goes below 1 he dies. given an array of stop with values (positive mean charging places with capacity and negative being the power requires to kill the alien) calculate the minimum power capacity he needs to have before starting the journey in order to safely reach stark tower. write the pseudo code and explain.
interesting question. I've seen quite a few like this. I guess you just need to check what's the minimum sum you can get to at any point in the array and calculate the number that will get that number to +1.
Code:
package main
import "fmt"
func main() {
arr := []int{0, -10, 3, -1, 11, -3, -5}
sum := 0
power := 1
for i := 0; i < len(arr); i++ {
sum += arr[i]
if sum < 0 {
v := (0 - sum) + 1
if v > power {
power = v
}
}
}
fmt.Println(power)
}
------
Post added on Jan 14, 2025 at 1:51 PM