Skip to content

Instantly share code, notes, and snippets.

View Jatin1o1's full-sized avatar
💭
Probably building something

Jatin Goyal Jatin1o1

💭
Probably building something
View GitHub Profile
@Jatin1o1
Jatin1o1 / 1_leetcode-graph-notes.txt
Created April 13, 2022 05:50 — forked from leetcode-notes/1_leetcode-graph-notes.txt
Solving common graph problems (2d grid) on leetcode
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
@Jatin1o1
Jatin1o1 / client.cpp
Created December 6, 2021 08:12 — forked from SteveRuben/client.cpp
Multiple streaming in c++ using opencv; OpenCV video streaming over TCP/IP
/**
* OpenCV video streaming over TCP/IP
* Client: Receives video from server and display it
* by Steve Tuenkam
*/
#include "opencv2/opencv.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
@Jatin1o1
Jatin1o1 / read PWM.ino
Created May 17, 2019 14:03
Reading Input PWM singal with arduino / demodulate PWM signals
byte PWM_IN = 3; // PWM input to be read at Arduino UNO's PWM pin 3
int value;
void setup()
{
pinMode(PWM_IN, INPUT); // initialising PWM_IN as an input pin
Serial.begin(115200); // serial begin at 115200 bauds
Serial.println (" Servo Angle Decoder ");
}
@Jatin1o1
Jatin1o1 / serial control multiple servos.ino
Created May 17, 2019 12:45
Controlling multiple servo motors using serial monitor without using void loop in arduino.
// the input to be sent to arduino is like " 1:90 " , " 0:45 " 2:135" to direct servo to go to that positions
#include <Servo.h>
int servoCount = 10;
int servoPins[] = {2,3,4,5,6,12,11,10,9,8};
Servo servos[10];
void setup() {
Serial.begin(115200);
@Jatin1o1
Jatin1o1 / servo_sweep_for_specific_time.ino
Created May 9, 2019 21:06
servo sweep for specific time duration
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(9);
Serial.begin(9600);
}
int jatin=2000; // interval for which servo will sweep
@Jatin1o1
Jatin1o1 / Arduino_LED_on_for_specific_interval .ino
Last active May 9, 2019 20:59
arduino file for turning led for specific interval
int ledpin=13; // led on pin 13
void setup() {
pinMode(ledpin,OUTPUT);
Serial.begin(9600); // serial monitor
}
int interval=4000; // time for led to remain on
unsigned long cm; // current milisecond