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 Node: | |
def __init__(self, key=-1, val=-1, prev=None, next=None): | |
self.key = key | |
self.val = val | |
self.prev = prev | |
self.next = next | |
class LRUCache: | |
def __init__(self, capacity: int): |
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: | |
def searchRange(self, nums: List[int], target: int) -> List[int]: | |
n = len(nums) | |
if n == 0: | |
return [-1, -1] | |
lo = 0 | |
hi = n - 1 | |
while lo < hi: | |
mid = lo + (hi - lo) // 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
class Solution: | |
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: | |
m = len(matrix) | |
if m == 0: | |
return False | |
n = len(matrix[0]) | |
if n == 0: | |
return False | |
# find last num in first column that <= target |
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
// thriftEncoding encapsulates thrift serializer/de-serializer. | |
type thriftEncoding struct{} | |
func toStructPtr(obj interface{}) interface{} { | |
val := reflect.ValueOf(obj) | |
vp := reflect.New(val.Type()) | |
vp.Elem().Set(val) | |
return vp.Interface() | |
} |
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
import static org.junit.Assert.assertTrue; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.util.ArrayList; | |
import java.util.List; |