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
/* | |
Given the constraints in the problem, our algo has to be at most O(n log n). We can acheive this bound using binary search | |
Suppose we have already created a function f(x) which, in O(n) time, can compute whether or not a subarray exists with median greater than (or equal to) x. Then, answering this question becomes as simple as finding the largest value of x such that f(x) is true. Finding this largest value of x can be done in O(log n) time with the method explained below. | |
If the maximum median of a test case is 5, the outputs of f(x) would look something like the following: | |
x: 1 2 3 4 5 6 7 8 9 | |
f(x): T T T T T F F F F |
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
// Place your key bindings in this file to override the defaultsauto[] | |
[ | |
{ | |
"key": "ctrl+enter", | |
"command": "code-runner.run" | |
}, | |
{ | |
"key": "ctrl+alt+n", | |
"command": "-code-runner.run" | |
}, |
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
{ | |
// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", |
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
{ | |
"editor.fontSize": 18, | |
"terminal.integrated.fontSize": 12, | |
"editor.fontFamily": "\"Fira Code Light\", \"Monoid\", \"JetBrainsMono Nerd Font Mono\"", | |
"workbench.colorTheme": "Dare (rainglow)", | |
"code-runner.executorMap": { | |
// "cpp": "cls && cd $dir && g++ $fileName -o \"C:\\Users\\ahmad\\OneDrive\\Desktop\\Coding\\IO\\bin\\$fileNameWithoutExt\" && C:\\Users\\ahmad\\OneDrive\\Desktop\\Coding\\IO\\bin\\$fileNameWithoutExt <C:\\Users\\ahmad\\OneDrive\\Desktop\\Coding\\IO\\input.txt> C:\\Users\\ahmad\\OneDrive\\Desktop\\Coding\\IO\\output.txt", | |
"cpp": "cls && cd $dir && g++ $fileName -o \"C:\\Users\\ahmad\\Desktop\\Coding\\!Workspace\\bin\\$fileNameWithoutExt\" && C:\\Users\\ahmad\\Desktop\\Coding\\!Workspace\\bin\\$fileNameWithoutExt <C:\\Users\\ahmad\\Desktop\\Coding\\!Workspace\\input.txt> C:\\Users\\ahmad\\Desktop\\Coding\\!Workspace\\output.txt" | |
}, | |
"code-runner.runInTerminal": true, |
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 | |
import ( | |
"fmt" | |
"math" | |
) | |
//Linked list structs | |
type node struct { | |
val int |
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 | |
import( | |
"fmt" | |
"math" | |
) | |
func main(){ | |
//Input (hardcode values if you are using Go Playground since it doesn't support terminal input) | |
var inputs [2]int |