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
| function beautifulDays(i, j, k) { | |
| // Write your code here | |
| const rev = (n) => { | |
| let num = Number(n.toString().split("").reverse().join("")) | |
| return num | |
| }; | |
| let beautifulDays = 0 | |
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
| def angryProfessor(k, a) | |
| # Write your code here | |
| on_time = 0 | |
| a.each do |s| | |
| on_time = on_time + 1 if s <= 0 | |
| end | |
| return 'YES' if on_time < k |
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
| def utopianTree(n) | |
| # Write your code here | |
| height = 1 | |
| return 1 if n <= 0 | |
| (1..n).each do |number| | |
| if number % 2 == 0 | |
| height = height + 1 |
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
| function designerPdfViewer(h, word) { | |
| // Write your code here | |
| let alphabet = 'abcdefghijklmnopqrstuvwxyz' | |
| let highest = 0; | |
| let currentHigh = 0; | |
| for(let i = 0 ; i < word.length ; i++ ){ | |
| currentHigh = h[alphabet.indexOf(word.charAt(i))] | |
| if(currentHigh > highest) { | |
| highest = currentHigh |
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
| function pickingNumbers(a) { | |
| // Write your code here | |
| let resultsArr = []; | |
| let tempArr = []; | |
| a.sort((a,b) => b-a); | |
| for(let x = 0; x < a.length ; x++) { | |
| tempArr.push(a[x]) | |
| for(let i = 0; i < a.length ; i++) { |
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
| function countingValleys(steps, path) { | |
| // Write your code here | |
| const moves = Array.from(path); | |
| let valleysCount = 0; | |
| let altitude = 0; | |
| let altitudesArray = []; | |
| for(let i = 0; i < moves.length; i += 1) { |
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
| function pageCount(n, p) { | |
| // Write your code here | |
| let flips = 0; | |
| let currentMaxPage = 1; | |
| let currentMinPage = p; | |
| if(n === 1 || p === 1) { |
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
| function sockMerchant(n, ar) { | |
| // Write your code here | |
| let socks = ar.sort((a,b) => a-b); | |
| let pairsCount = 0; | |
| while (socks.length > 0) { | |
| if (socks[0] === socks[1]) { | |
| pairsCount += 1; | |
| socks.shift(); |
NewerOlder