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
// '[]{}()' - allowed characters | |
// Assusming that only above characters are used. Write a code to validate the given pattern. | |
// '[{[()]}]' - valid | |
// '[{[()]}]{[{()}]}' - valid | |
// '[()[]]' | |
// '[{[()]]}]' - not valid | |
// '[}' - not valid | |
// '[{]}' - not valid | |
// '[]{}' - valid |
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
function sort(arr) { | |
let last_index = arr.length - 1; | |
while (last_index > 0) { | |
heapify(arr, last_index); | |
swap(0, last_index, arr); | |
last_index--; | |
} | |
return arr; | |
} | |
function heapify(arr, last_index) { |
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
module.exports = req.random_number = Math.floor(Math.random()*10); |