Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sorting and Searching/Auction/auction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -64,4 +64,4 @@ int main(){
cout << customer[i] << " ";
}

}
}
17 changes: 13 additions & 4 deletions Symphony/subarray_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<n; i++) {
for (int j=i; j<n; j++) {
int sum_of_this_subarray = 0;
for (int k=i; k<=j; k++) {
sum_of_this_subarray += array[k];
}

if (ender==1){

for (int k=i; k<=j; k++) {

sum_of_this_subarray += array[k];
ender++;
}
}
else {sum_of_this_subarray= sum_of_this_subarray + array[j+1];}

best_sum = max(best_sum, sum_of_this_subarray);
}
}
Expand Down