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
| $n = 1000000; | |
| $time1 = microtime(true); | |
| $mem1 = memory_get_usage(true); | |
| for ($i = 0; $i < $n; $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 messageFromBinaryCode(code) { | |
| return code.match(/.{8}/g).reduce((a,b)=>a+String.fromCharCode(parseInt(b,2)),"") | |
| } |
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
| // Singly-linked lists are already defined with this interface: | |
| // function ListNode(x) { | |
| // this.value = x; | |
| // this.next = null; | |
| // } | |
| // | |
| function addTwoHugeNumbers(a, b) { | |
| var sum = null, | |
| tmp, | |
| carry = 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
| // Singly-linked lists are already defined with this interface: | |
| // function ListNode(x) { | |
| // this.value = x; | |
| // this.next = null; | |
| // } | |
| // | |
| function removeKFromList(l, k) { | |
| var curr; | |
| // remove leading k values with changing l |
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
| set @r1=0, @r2=0, @r3=0, @r4=0; | |
| select min(Doctor), min(Professor), min(Singer), min(Actor) | |
| from( | |
| select case when Occupation='Doctor' then (@r1:=@r1+1) | |
| when Occupation='Professor' then (@r2:=@r2+1) | |
| when Occupation='Singer' then (@r3:=@r3+1) | |
| when Occupation='Actor' then (@r4:=@r4+1) end as RowNumber, | |
| case when Occupation='Doctor' then Name end as Doctor, | |
| case when Occupation='Professor' then Name end as Professor, | |
| case when Occupation='Singer' then Name end as Singer, |
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
| select | |
| case | |
| when a + b <= c or a + c <= b or b + c <=a then 'Not A Triangle' | |
| when a = b and b = c then 'Equilateral' | |
| when a = b or b = c or a = c then 'Isosceles' | |
| else 'Scalene' | |
| end as triangle_type | |
| from TRIANGLES; |
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 reverseInParentheses(s) { | |
| while (true) { | |
| let c = s.indexOf(")"); | |
| if (c === -1) { | |
| break; | |
| } | |
| let o = s.substring(0, c).lastIndexOf("("); | |
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 adjacentElementsProduct(inputArray) { | |
| var arrayLength = inputArray.length; | |
| var largestProduct = inputArray[0] * inputArray[1]; | |
| for (var i = 1; i < arrayLength - 1; i++) { | |
| largestProduct = Math.max(largestProduct, inputArray[i] * inputArray[i + 1]); | |
| } | |
| return largestProduct; | |
| } |
NewerOlder