Munish Bansal
BAN USER
there are some issues while editing.. hence posting answer again
public static void longestPositiveSequence(int[] arr) {
int index, tempIndex;
int length, tempLength;
index = tempIndex = -1;
length = tempLength = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0) {
if (tempLength > length) {
length = tempLength;
index = tempIndex;
}
tempLength = 0;
tempIndex = i + 1;
} else {
tempLength++;
}
}
if (index != -1) {
System.out.println("Index : " + index + ", length : " + length);
} else {
System.out.println("No result found");
}
}
there is no need of flag here
- Munish Bansal April 15, 2015
Repleroydperry, Backend Developer at AppNexus
I am from the USA. I am 27 year old. I drive the train for my company Monk Home Funding ...
Repomarcdei, Android Engineer at Abs india pvt. ltd.
I'm Omar. I am working as a Mail carrier in Manning's Cafeterias company. I love to learn and ...
RepEvieBBlack, AT&T Customer service email at ASAPInfosystemsPvtLtd
I am Evie from Santa Fe Springs USA, I am working as a manager in a worldwide company. I also ...
Repadak4257, Applications Developer at Adobe
I am fond of Listening Songs then reading newspapers which are all about a story of a beautiful nature and ...
Repjoycepwise, Blockchain Developer at Accenture
Hello, I’m Joyce. I’m a business developer living in Tampa, FL. I am a fan of music, travel ...
Repcharlespladd, Android Engineer at Abs india pvt. ltd.
I am Charles from Pascoag USA. I have strong knowledge of pain management systems. And I have experience in providing ...
- Munish Bansal April 15, 2015