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 dayOfProgrammer(year) { | |
| // Write your code here | |
| if (year === 1918) { | |
| return '26.09.1918'; | |
| } | |
| const checkLeapYear = (year) => { | |
| if (year >= 1919) { | |
| if (year % 400 === 0) { | |
| return true; |
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
| https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true | |
| const migratoryBird = (arr) => { | |
| let i = 0; | |
| let x = -1; | |
| let splitedArr = []; | |
| arr.sort((a,b) => (a-b)) | |
| while ( i < arr.length ) { |
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
| https://www.hackerrank.com/challenges/the-birthday-bar/problem?isFullScreen=true | |
| function birthday(s, d, m) { | |
| // Write your code here | |
| if ( s.length === 1 ) { | |
| if (s[0] === d) { | |
| return 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 divisibleSumPairs(n, k, ar) { | |
| // Write your code here | |
| let total = 0; | |
| let x = 0; | |
| for (let x = 0; x < ar.length + 1; x++) { | |
| for (let i = 0; i < ar.length; i++) { | |
| if (i !== x) { | |
| if ((ar[x] + ar[i]) % k === 0) { | |
| total += 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
| def simple_quicksort(array) | |
| # write your code here | |
| return if array.empty? | |
| final = [] | |
| pivot = array.first | |
| left = [] | |
| right = [] |
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
| const gradingStudents = (grades) => { | |
| let scores = []; | |
| for (let i = 0; i < grades.length; i++) { | |
| if (grades[i] < 38) { | |
| scores.push(grades[i]) | |
| continue; | |
| } |
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
| const groupAnagrams = (strs) => { | |
| let copyArr = [...strs] | |
| let finalArr = []; | |
| for (let i = 0; i < copyArr.length; i++) { | |
| copyArr[i] = copyArr[i].split("").sort().join(""); | |
| } | |
| while (strs.length > 0) { | |
| let i = 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
| const kangaroo = (x1, v1, x2, v2) => { | |
| let start1 = x1 + v1 | |
| let start2 = x2 + v2 | |
| if (start1 === start2) { | |
| return 'YES' | |
| } | |
| for (let i = 0 ; i <= 10000 ; i++ ) { | |
| if((start1 + v1) === (start2 + v2)) { |
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
| const countApplesAndOranges = (s, t, a, b, apples, oranges) => { | |
| let applesInside = 0; | |
| let orangesInside = 0; | |
| for(let i = 0 ; i < apples.length ; i++) { | |
| if ((apples[i] + a) >= s && (apples[i] + a) <= t ) { | |
| applesInside += 1; | |
| } | |
| } |
NewerOlder