8/29/20 (Sliding Window)
- https://leetcode.com/problems/sliding-window-median/
- https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/
- Extra
8/27/20 (Binary Search)
Grid problems are almost always just graph problems and typically straightforward ones. I initially found them a bit weird because in algorithm classes they present graphs as adjacency nodes or adjacency matrices. In a grid, each cell is a node, and it's neighbors are the four-directional neighboring cells or sometimes 8-directional, if the problem at hand allows travel in all the diagonals in addition to up, down, left, right. The vertices are not explicit but usually we don't need to worry about them in these problems. | |
There is nothing special about a grid vs another type of graph representation. Just need to tweak the grpah algorithms at our disposal. | |
Basic graph techniques: | |
BFS- traverses the entire graph, going layer by layer expanding from the starting point. It allows us to do a couple of things, count connected components in a graph, find the shortest distance from one cell to another cell. While traversing, | |
we need to track visited cells. You can do that by changing the cell value (coloring) or r |
8/29/20 (Sliding Window)
8/27/20 (Binary Search)
Picking the right architecture = Picking the right battles + Managing trade-offs
from apiclient.discovery import build | |
def build_service(filename): | |
with open(filename) as f: | |
key = f.readline() | |
YOUTUBE_API_SERVICE_NAME = "youtube" | |
YOUTUBE_API_VERSION = "v3" | |
return build(YOUTUBE_API_SERVICE_NAME, | |
YOUTUBE_API_VERSION, |
<?php | |
namespace App\Service\Pay; | |
/** | |
* TaiwanPay | |
*/ | |
class TaiwanPay | |
{ | |
/** |
.css-selector { | |
background: linear-gradient(147deg, #6d2ff6, #6dac67); | |
background-size: 400% 400%; | |
-webkit-animation: AnimationName 11s ease infinite; | |
-moz-animation: AnimationName 11s ease infinite; | |
-o-animation: AnimationName 11s ease infinite; | |
animation: AnimationName 11s ease infinite; | |
} | |
@-webkit-keyframes AnimationName { | |
0%{background-position:9% 0%} |
#predicting the streaming kafka messages | |
consumer = KafkaConsumer('twitter-stream',bootstrap_servers=\['localhost:9092']) | |
print("Starting ML predictions.") | |
for message in consumer: | |
X_new_counts = count_vect.transform([message.value]) | |
X_new_tfidf = tfidf_transformer.transform(X_new_counts) | |
predicted = load_model.predict(X_new_tfidf) | |
print(message.value+" => "+fetch_train_dataset(categories).target_names[predicted[0]]) |