Created
December 19, 2023 13:13
-
-
Save MrZoidberg/923cf7cc6c1ca1fe53505eeb2b33bb01 to your computer and use it in GitHub Desktop.
Integer Bag (Golang)
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
package main | |
type IntegerBag interface { | |
// Gt counts the number of items in the bag greater than or equal (>=) {@Code int} | |
// @param i - The number to compare each integer to. | |
// @return - How many integers match the criteria. | |
Gt(i int) int | |
// Ge counts the number of items in the bag greater than (>) {@Code int} | |
// @param i - The number to compare each integer to. | |
// @return - How many integers match the criteria. | |
Ge(i int) int | |
// Lt counts the number of items in the bag less than (<) {@Code int} | |
// @param i - The number to compare each integer to. | |
// @return - How many integers match the criteria. | |
Lt(i int) int | |
// Le counts the number of items in the bag less than or equal (<=) {@Code int} | |
// @param i - The number to compare each integer to. | |
// @return - How many integers match the criteria. | |
Le(i int) int | |
// Count returns the number of items in the bag. | |
Count() int | |
} | |
// Task: Find the median. | |
// The median is the number that will appear in the middle if the contents of the bag were ordered in their natural order (i.e. ascending). | |
// If the count is even, the median can be the number to the left of right. | |
// Examples: | |
// 1 3 7 | |
// 1 3 4 5 6 | |
// 1 2 3 4 5 | |
// 10 11 12 14 | |
// 1 1 1 2 3 4 5 6 7 | |
// 1 1 2 2 10m 11m 12m 13m 14m | |
func your_code_goes_here(bag IntegerBag) int { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment