Skip to content

Instantly share code, notes, and snippets.

View rambabu-patidar's full-sized avatar
🎯
Focusing

Rambabu Patidar rambabu-patidar

🎯
Focusing
View GitHub Profile
@rambabu-patidar
rambabu-patidar / websocket.md
Created January 24, 2026 14:33
Very very simple example of how you can use websocket for bi-directional communication between client and server.

WebSocket

This code comes from this youtube channel The Complete Guide to WebSockets one of the best channel to learn Networking and Deep dive concepts of System Design etc.

const http = require("http");
const WebSocket = require("websocket").server;

let connection = null;
@rambabu-patidar
rambabu-patidar / Sunday-leetcode-trauma.md
Created January 18, 2026 11:34
The day when Leetcode decided to put everyone on depression.

My Trauma:

What long code I have to write today to get my solution accepted. Ohh God!! But I did it.

LC 3814 : Maximum Capacity within Budget (Took Hint) : Contest Question

class Solution {
public:
@rambabu-patidar
rambabu-patidar / Dijkstra-algorithm.md
Last active January 6, 2026 17:31
Actually this has two version with slightly different ways but same functionality.

Dijkstra's Algorithm

We use Dijkstra algorithm to find the minimum distance from single srouce(src) to all other vertex in the given graph. It works only on Undirected Weighted Graph which are not having negative edge weights. It uses a greedy approach that repeatedly minimize the distances to other vertices.

We use priority queue to implement Dijkstra's algorithm.

The theory part you can learn on the Internet.

Approach 01: Using the Visited Array

Some basics first before main question!

__dirname : This gives us the path from the OS to the folder in which you used it. (important is folder here because we used this command in some file that reside inside that folder) FOR EXAMPLE: C:\Users\Lenovo\Desktop\Fun\routes\shop.js this is the path in which we used __dirname then we will going to get path upto C:\Users\Lenovo\Desktop\Fun\routes\

__filename: This command when used gives the full path from OS to the file in which we used it. So for above example we will get C:\Users\Lenovo\Desktop\Fun\routes\shop.js

Now we know that node js ships with it a core module that is path module.

@rambabu-patidar
rambabu-patidar / minimum-spanning-tree.md
Last active January 6, 2026 19:29
minimum-spanning-tree

MINIMUM SPANNING TREE NOTES

ST(Spanning Tree) is a tree like subgraph of a connected, undirected graph that include all the vertices of the graph. In simple words, It is a tree like structure (hence no cycle) where the edges are the subset of graph and vertices are the exact set of original graph.

MST is excatly same like ST but with one more constraint of having minimum weight sum of edges.

Properties

@rambabu-patidar
rambabu-patidar / bubbleSort.cpp
Created August 16, 2023 14:15
Bubble sort resursive.
#include<bits/stdc++.h>
using namespace std;
void swap(vector<int>& nums, int i, int j)
{
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
@rambabu-patidar
rambabu-patidar / TestingLibraryElementError.txt
Created July 26, 2023 17:30
TestingLibraryElementError while build with Node.js workflow
Run npm test
> food-order-website@0.1.0 test
> react-scripts test
FAIL src/App.test.js
✕ renders learn react link (88 ms)
● renders learn react link
@rambabu-patidar
rambabu-patidar / cycleDetectUsingBFS.cpp
Created July 19, 2023 05:28
Detect cycle in undirected Graph using BFS
#include<bits/stdc++.h>
using namespace std;
class Graph
{
private:
int n;
vector<int> *list;
public:
@rambabu-patidar
rambabu-patidar / cycleDetectUsingDFS.cpp
Created July 19, 2023 05:27
Detect cycle in undirected graph using DFS
#include <bits/stdc++.h>
using namespace std;
// to detect cycle in undirected graph we will keep track of the parent node
// if the nbr of a vertex is visited and not its parent that means cycle is present.
// we have to keep track of parent because in undirected graph visited node can be its parent
// which is not considered as back edge.
class Graph
{
@rambabu-patidar
rambabu-patidar / bubbleSort.cpp
Created April 12, 2023 18:01
code for bubble sorting algorithm.
#include<iostream>
using namespace std;
void bubbleSort( int arr[], int n){
for( int i=1;i<=n-1;i++){
for(int j=0;j<=n-i;j++){//if u don't want to start the j loop from 1
//then start it from 1 but theu arr[j] will be replaced by arr[j-1]
if( arr[j]>arr[j+1]){
int temp = arr[j];
arr[j]= arr[j+1];