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
| INCR id:users | |
| HMSET users {id} '{"name":"Fred","age":25}' |
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
| INCR id:users | |
| HMSET user:{id} name "Fred" age 25 | |
| SADD users {id} |
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
| INCR id:users | |
| SET user:{id} '{"name":"Fred","age":25}' | |
| SADD users {id} |
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
| INCR id:users | |
| SET user:{id}:name "Fred" | |
| SET user:{id}:age 25 | |
| SADD users {id} |
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
| long x = long.MinValue; | |
| public long ID(){ | |
| return Interlocked.Increment(ref x); | |
| } |
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
| private static long fibonacci(int n) { | |
| double pha = pow(1 + sqrt(5), n); | |
| double phb = pow(1 - sqrt(5), n); | |
| double div = pow(2, n) * sqrt(5); | |
| return (long)((pha - phb) / div); | |
| } |
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 sqrt = Math.sqrt; | |
| const pow = Math.pow; | |
| const fibCalc = n => Math.round( | |
| (1 / sqrt(5)) * | |
| ( | |
| pow(((1 + sqrt(5)) / 2), n) - | |
| pow(((1 - sqrt(5)) / 2), n) | |
| ) | |
| ); |
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
| class Solution(object): | |
| def reverseList(self, head): # Recursive | |
| """ | |
| :type head: ListNode | |
| :rtype: ListNode | |
| """ | |
| if not head or not head.next: | |
| return head | |
| p = self.reverseList(head.next) | |
| head.next.next = head |
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 BinaryTreeToDLL(self, node): | |
| #Checks whether node is None | |
| if(node == None): | |
| return; | |
| #Convert left subtree to doubly linked list | |
| self.BinaryTreeToDLL(node.left); | |
| #If list is empty, add node as head of the list | |
| if(self.head == None): |
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 fibonacci(num, memo) { | |
| memo = memo || {}; | |
| if (memo[num]) return memo[num]; | |
| if (num <= 1) return 1; | |
| return memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo); | |
| } |