## pvpkiran

BAN USER- 0 Answers
**Algorithm**There is a rope on which you will put clothes to dry. And each cloth is of different length and their starting position on the cloth is also different. Once all the clothes are put on the rope. we have to find out how many clothes are visible if i look it from top.

- pvpkiran September 01, 2014

You are given two inputs.

1. length of the rope

2. And a list of Cloth Objects.

List<Cloth>

Cloth class is defined like this

class Cloth{

int initial Position,

int clothLength

}

for example if i am given rope length of 7

and List of cloth objects which has 3 Cloth Objects C1, C2, C3

C1.initialPosition = 0

C1.clothLength = 5(this cloth will cover from 0 to 5)

C2.initialPosition = 2

C2.clothLength = 2 (this cloth will cover from 2 to 4. since length of cloth =2)

C3.initialPosition = 1

C3.clothLength = 5 (this cloth will cover from 1 to 6. since length of cloth =5)

So with this. we can only see Cloth 1 and Cloth 3. So the output should be 2

Imagine the rope like this.

|........|.........|.........|..........|..........|...........|...........|

0 1 2 3 4 5 6 7| Flag | PURGE - 12 Answers
**array puzzle load balance**There is a array indicating the load on each server like this

- pvpkiran February 14, 2014

0,0,10,0,0,0,0,0,0,0

each servers can share load with its neighbours, and it can only share 1 unit per second. like this

0,1,8,1,0,0,0,0,0,0

so how many seconds needed to distribute the load equally.

so for the above case the next step is

1,1,6,1,1,0,0,0,0,0

so totally this sequence needs 7 seconds to make it

1,1,1,1,1,1,1,1,1,1

for the case where input is 27,28

the result shud be 0. Because it can't be balanced.| Flag | PURGE

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

Hi,

- pvpkiran February 23, 2014The solution what u said is working. I am just curious on how did u come up with this? what is the logic behind this. Can I know?