diff --git a/Sorting and Searching/Auction/auction.cpp b/Sorting and Searching/Auction/auction.cpp index ab8e6b5..d153260 100755 --- a/Sorting and Searching/Auction/auction.cpp +++ b/Sorting and Searching/Auction/auction.cpp @@ -35,7 +35,7 @@ int main(){ int boughtIndex = getMinIndex(price); // Index with minimum price for(int j = 0; j < n; j++){ - if(price[j] > price[boughtIndex] && !bought[boughtIndex] && price[j] <= customer[i]){ + if(price[j] > price[boughtIndex] && !bought[j] && price[j] <= customer[i]){ boughtIndex = j; } } @@ -64,4 +64,4 @@ int main(){ cout << customer[i] << " "; } -} \ No newline at end of file +} diff --git a/Symphony/subarray_sum.cpp b/Symphony/subarray_sum.cpp index e2df6f2..7ca7030 100644 --- a/Symphony/subarray_sum.cpp +++ b/Symphony/subarray_sum.cpp @@ -7,12 +7,21 @@ int max_subarray_sum(int *array, int n) { // Go through all possible subarays // Maintain a maximum of their sum, return the maximum int best_sum = 0; + int sum_of_this_subarray = 0; + int ender=1; for (int i=0; i