Last active
September 18, 2022 05:22
-
-
Save agambondan/2c839c5f0148ab0db08ff031df318a9c to your computer and use it in GitHub Desktop.
Filter Item Price And Quantity
This file contains hidden or 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
package main | |
import "fmt" | |
// SolutionFilter is your solution code. | |
func SolutionFilter(N int, itemList [][]int, M int, query [][]int) { | |
// Your code starts here. | |
var count = make([]int, M) | |
for i := 0; i < M; i++ { | |
for k := 0; k < N; k++ { | |
if (query[i][0] <= itemList[k][0] && itemList[k][0] <= query[i][1]) && (query[i][2] <= itemList[k][1] && itemList[k][1] <= query[i][3]) { | |
count[i] += 1 | |
} | |
} | |
} | |
for _, v := range count { | |
fmt.Println(v) | |
} | |
} | |
func main() { | |
var itemList = [][]int{{5, 2}, {4, 2}, {7, 7}, {8, 3}, {4, 5}} | |
var query = [][]int{{5, 5, 2, 2}, {4, 7, 5, 7}, {4, 8, 2, 7}} | |
SolutionFilter(len(itemList), itemList, len(query), query) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment