Created
April 12, 2018 09:39
-
-
Save joe-crick/62a3889ebbccf0f89001e4b326db38e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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