Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar Roy committed Dec 30, 2015
1 parent ebbfe01 commit 48a099c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions python/array/flip0smaximum1s.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def flip_0s_to_maximize_consecutive_1s(input, flips_allowed):
else:
if count_zero < flips_allowed:
count_zero = count_zero + 1
result = max(result, i - window_start + 1)
else:
while True:
if input[window_start] == 0:
Expand Down
1 change: 1 addition & 0 deletions python/array/longestsamesumspan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def longest_span(input1, input2):
prefix1 = 0
prefix2 = 0
max_span = 0
diff[0] = -1
for i in range(len(input1)):
prefix1 += input1[i]
prefix2 += input2[i]
Expand Down
1 change: 1 addition & 0 deletions src/com/interview/array/Flip0sMaximum1s.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public int flip0sToMaximizeConsecutive1s(int input[], int flipsAllowed) {
} else {
if (countZero < flipsAllowed) {
countZero++;
result = Math.max(result, i - windowStart + 1);
} else {
while(true) {
if (input[windowStart] == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/com/interview/array/LongestSameSumSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public int longestSpan(int input1[], int input2[]) {
Map<Integer, Integer> diff = new HashMap<>();
int prefix1 = 0, prefix2 = 0;
int maxSpan = 0;
diff.put(0, -1);
for (int i = 0; i < input1.length ; i++) {
prefix1 += input1[i];
prefix2 += input2[i];
Expand All @@ -38,9 +39,8 @@ public int longestSpan(int input1[], int input2[]) {
}

public static void main(String args[]) {
int input1[] = {0, 1, 0, 1, 1, 1, 1};
int input2[] = {1, 1, 1, 1, 1, 0, 1};

int input1[] = {1, 0, 0, 1, 1, 0};
int input2[] = {0, 1, 1, 0, 1 ,1};
LongestSameSumSpan lsss = new LongestSameSumSpan();
System.out.print(lsss.longestSpan(input1, input2));
}
Expand Down

0 comments on commit 48a099c

Please sign in to comment.