This file contains 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 org.json4s.DefaultFormats.++ | |
//import org.json4s.JsonDSL.int2jvalue | |
object Solution extends App { | |
def twoSum(nums: Array[Int], target: Int): Option[Array[Int]] = { | |
var leftIndex: Int = 0 | |
while (leftIndex < nums.length -1) { | |
println("*****") |
This file contains 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
-- Write your PostgreSQL query statement below | |
select | |
s.student_id, | |
s.student_name, | |
j.subject_name, | |
sum(case when e.subject_name is null then 0 else 1 end) as attended_exams | |
from | |
Students s | |
Cross join Subjects j | |
left join Examinations e |
This file contains 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
-- Write your PostgreSQL query statement below | |
/* | |
Lets first do a table scan to get every process_id's time delta | |
*/ | |
with process_time_delta as ( | |
Select | |
machine_id, | |
process_id, | |
activity_type, | |
timestamp, |
This file contains 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
-- Write your PostgreSQL query statement below | |
select | |
id as Id | |
from | |
( | |
select | |
id, | |
recordDate, | |
temperature, | |
LAG(temperature, 1) OVER ( |
This file contains 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 __init__(self): | |
self.max_area = 0 | |
def getLength(self, index_left, index_right) -> int: | |
return index_right - index_left | |
def maxArea(self, height: List[int]) -> int: |
This file contains 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 __init__(self): | |
self.numeric_set = [str(i) for i in range(10)] | |
self.allowed_set = self.numeric_set | |
self.allowed_set.append("-") | |
This file contains 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
""" | |
`X` means part of a ship is here | |
`.` means it is an empty spot | |
""" | |
board = [ | |
["X", ".", "X", ".", "X", "X"], | |
["X", ".", ".", ".", ".", "."], | |
["X", ".", "X", ".", "X", "."] | |
] |
This file contains 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 is_Same(char_one: str, char_two: str) -> bool: | |
return char_one == char_two | |
class Solution: | |
def __init__(self): | |
#todo: could initialize some class vars like s_chars, s_pointer, s_pal_longest | |
pass |
This file contains 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 findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: | |
# first merge the arrays | |
merged = nums1 + nums2 | |
# sort it inplace | |
merged.sort() | |
#todo: now we need to find median | |
# find the length | |
merged_len = len(merged) |
This file contains 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
# Definition for singly-linked list. | |
class ListNode: | |
def __init__(self, val=0, next=None): | |
self.val = val | |
self.next = next | |
class Solution: | |
def mergeKLists(self, lists: List[Optional[ListNode]]) -> List: | |
out_list = [] |
NewerOlder