Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
105 changes: 100 additions & 5 deletions Arrays_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
# return True
# return False
#
#
# def sub_array_sum(arr: List[int], k: int) -> int:

# def sub_array_sum(arr: list[int], k: int) -> int:
# if not arr:
# return null
# prefix_sum = 0
Expand All @@ -65,6 +65,7 @@
# freq[prefix_sum] += 1
#
# return count
# print(sub_array_sum([1,1,1,1,1,1,1],3))
#
# # print(reverse_array([1,2,3,4,5,6]))
# # print(return_sorted([123,213,2,42,123,-12,2,323]))
Expand All @@ -74,7 +75,7 @@
# # print(sum([1,2,3,4]))
#
#
# print(sub_array_sum([1,1,1,1,1,1,1],3))

#
# from typing import List
#
Expand Down Expand Up @@ -544,7 +545,101 @@
# j += 1
# merged.extend(left[i:])
# merged.extend(right[j:])
return merged
# return merged


# print(merge_sort([12, 23123, 2, 33, 12, 2, 1, 45, 57, 8, 32312, 2223, 3]))

# class TwoSum:
# def __init__(self):
# self.nums = []
#
# def add(self, number: int):
# self.nums.append(number)
#
# def find(self, target: int) -> bool:
# seen = set()
# for num in self.nums:
# if target - num in seen:
# return True
# seen.add(num)
# return False
#
# stream = TwoSum()
# stream.add(3)
# stream.add(5)
# stream.add(7)
#
# print(stream.find(10)) #→ True # 3 + 7
# stream.find(8) #→ True # 3 + 5
# print(stream.find(15)) #→ False

from typing import List


# def top_k_frequent(nums: list[int], k: int) -> list[int]:
# if not nums:
# return [0]
# nums_counter = Counter(nums)
# return nums_counter.most_common(k)
#
# print(top_k_frequent([1,1,1,1,1,1,2,2,2,2,2,3,3],2))

from collections import defaultdict

# def product_except_self(nums: list[int]) -> list[int]:
# n = len(nums)
# output = [1] * n
#
# # First pass: left → right
# left_product = 1
# for i in range(n):
# output[i] = left_product
# left_product *= nums[i]
# print(output)
#
# # Second pass: right → left
# right_product = 1
# for i in range(n - 1, -1, -1):
# output[i] *= right_product
# right_product *= nums[i]
#
# return output

# print()
#
# # nums = [1,2,3,4]
# # for i,num in enumerate(nums[::-1]):
# # print(i,num)


from collections import deque
from typing import List, Tuple


def rolling_unique_users(events: List[Tuple[int, str]]) -> List[Tuple[int, int]]:
if not events:
return []

window = deque()
result = []

for timestamp, user in events:
window.append((timestamp, user))
while window and timestamp - window[0][0] >= 60:
window.popleft()
unique_user = set(u for _, u in window)
result.append((timestamp, len(unique_user)))

return result


events = [
(1, "u1"),
(2, "u2"),
(61, "u1"),
(62, "u3"),
(120, "u2"),
]

print(merge_sort([12, 23123, 2, 33, 12, 2, 1, 45, 57, 8, 32312, 2223, 3]))
print(rolling_unique_users(events))
211 changes: 211 additions & 0 deletions comparison_fusion_map.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<!DOCTYPE html>
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>

<meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
#map_12d775dad7024baa3484059f1cdb4a98 {
position: relative;
width: 100.0%;
height: 100.0%;
left: 0.0%;
top: 0.0%;
}
.leaflet-container { font-size: 1rem; }
</style>

<style>html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>

<style>#map {
position:absolute;
top:0;
bottom:0;
right:0;
left:0;
}
</style>

<script>
L_NO_TOUCH = false;
L_DISABLE_3D = false;
</script>


</head>
<body>


<div class="folium-map" id="map_12d775dad7024baa3484059f1cdb4a98" ></div>

</body>
<script>


var map_12d775dad7024baa3484059f1cdb4a98 = L.map(
"map_12d775dad7024baa3484059f1cdb4a98",
{
center: [43.642415, -79.396512],
crs: L.CRS.EPSG3857,
...{
"zoom": 20,
"zoomControl": true,
"preferCanvas": false,
}

}
);





var tile_layer_15eafc5b83e460aa447d8c007b25bb36 = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{
"minZoom": 0,
"maxZoom": 19,
"maxNativeZoom": 19,
"noWrap": false,
"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors",
"subdomains": "abc",
"detectRetina": false,
"tms": false,
"opacity": 1,
}

);


tile_layer_15eafc5b83e460aa447d8c007b25bb36.addTo(map_12d775dad7024baa3484059f1cdb4a98);


var marker_1eb10c660bed4aeb3693dd8a758f1c9b = L.marker(
[43.642415, -79.396512],
{
}
).addTo(map_12d775dad7024baa3484059f1cdb4a98);


var icon_02149710100d6588d1b5681f43c97044 = L.AwesomeMarkers.icon(
{
"markerColor": "blue",
"iconColor": "white",
"icon": "info-sign",
"prefix": "glyphicon",
"extraClasses": "fa-rotate-0",
}
);


marker_1eb10c660bed4aeb3693dd8a758f1c9b.bindTooltip(
`<div>
Start
</div>`,
{
"sticky": true,
}
);


marker_1eb10c660bed4aeb3693dd8a758f1c9b.setIcon(icon_02149710100d6588d1b5681f43c97044);


var marker_421b10dc4b956ed76b77d028d25f28e1 = L.marker(
[43.642446, -79.396452],
{
}
).addTo(map_12d775dad7024baa3484059f1cdb4a98);


var icon_6237a39afb949d0eec68b1af7adca72b = L.AwesomeMarkers.icon(
{
"markerColor": "black",
"iconColor": "white",
"icon": "flag",
"prefix": "glyphicon",
"extraClasses": "fa-rotate-0",
}
);


marker_421b10dc4b956ed76b77d028d25f28e1.bindTooltip(
`<div>
End
</div>`,
{
"sticky": true,
}
);


marker_421b10dc4b956ed76b77d028d25f28e1.setIcon(icon_6237a39afb949d0eec68b1af7adca72b);


var poly_line_680123b84116621cada9194c4e99915c = L.polyline(
[[43.642415, -79.396512], [43.642438, -79.396517], [43.642446, -79.396452]],
{"bubblingMouseEvents": true, "color": "blue", "dashArray": null, "dashOffset": null, "fill": false, "fillColor": "blue", "fillOpacity": 0.2, "fillRule": "evenodd", "lineCap": "round", "lineJoin": "round", "noClip": false, "opacity": 1.0, "smoothFactor": 1.0, "stroke": true, "weight": 3}
).addTo(map_12d775dad7024baa3484059f1cdb4a98);


poly_line_680123b84116621cada9194c4e99915c.bindTooltip(
`<div>
Actual GPS
</div>`,
{
"sticky": true,
}
);


var poly_line_aaeb67abedf58860f423e870fd59fd1b = L.polyline(
[[43.642415, -79.396512], [43.642438, -79.396517], [43.642446, -79.396452]],
{"bubblingMouseEvents": true, "color": "green", "dashArray": null, "dashOffset": null, "fill": false, "fillColor": "green", "fillOpacity": 0.2, "fillRule": "evenodd", "lineCap": "round", "lineJoin": "round", "noClip": false, "opacity": 1.0, "smoothFactor": 1.0, "stroke": true, "weight": 3}
).addTo(map_12d775dad7024baa3484059f1cdb4a98);


poly_line_aaeb67abedf58860f423e870fd59fd1b.bindTooltip(
`<div>
Basic Fusion
</div>`,
{
"sticky": true,
}
);


var poly_line_62bd99b19b0c798eafe39867a420e7c4 = L.polyline(
[[43.642415, -79.396512], [43.642438, -79.396517], [43.642446, -79.396452]],
{"bubblingMouseEvents": true, "color": "pink", "dashArray": null, "dashOffset": null, "fill": false, "fillColor": "pink", "fillOpacity": 0.2, "fillRule": "evenodd", "lineCap": "round", "lineJoin": "round", "noClip": false, "opacity": 1.0, "smoothFactor": 1.0, "stroke": true, "weight": 3}
).addTo(map_12d775dad7024baa3484059f1cdb4a98);


poly_line_62bd99b19b0c798eafe39867a420e7c4.bindTooltip(
`<div>
Refined Fusion
</div>`,
{
"sticky": true,
}
);

</script>
</html>
Loading