Skip to content

Instantly share code, notes, and snippets.

@joe-crick
Created April 12, 2018 09:39
Show Gist options
  • Save joe-crick/62a3889ebbccf0f89001e4b326db38e1 to your computer and use it in GitHub Desktop.
Save joe-crick/62a3889ebbccf0f89001e4b326db38e1 to your computer and use it in GitHub Desktop.
// Segment Tree
getSmallestBidFromRange() {
const start = parseInt(this.start);
const end = parseInt(this.end);
this.smallestValue = this.segmentTree.rangeMinQuery(start, end);
}
// Array
getSmallestBidFromRange() {
const start = parseInt(this.start);
const end = parseInt(this.end);
this.smallestValue = this.items
.filter(bidsInRange(start, end))
.reduce((cur, prev) => {
if (prev) {
return cur;
} else {
return cur.bid < prev.bid ? cur : prev;
}
}).bid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment