Skip to content

Instantly share code, notes, and snippets.

View Ch-sriram's full-sized avatar
🎯
Achieving Greatness | Non-stop Hustling

Sriram Chandrabhatta Ch-sriram

🎯
Achieving Greatness | Non-stop Hustling
View GitHub Profile
@Ch-sriram
Ch-sriram / git_lfs.sh
Created January 31, 2025 12:20
GitHub LFS [Large File System] Commands
git lfs install # if git config is not currently configured for LFS
git lfs track "*.jpg" "*.png" # track all jpg and png files (recursively)
git add .gitattributes **/*.jpg **/*.png # add .gitattributes and LFS artifacts (recursively)
git lfs ls-files # optional: ensure your LFS files are tracked before committing
git commit -m "Tracking and adding LFS artifacts"
git push
@Ch-sriram
Ch-sriram / getAllKeyCombinationsInDeeplyNestedObject.js
Last active November 4, 2024 21:04
Get all possible key combinations in a deeply nested object
const deeplyNestedObject = {
name: "John Doe",
age: 30,
address: {
street: "123 Main St",
city: "Somewhere",
postalCode: "12345",
coordinates: {
latitude: 37.7749,
longitude: -122.4194,
@Ch-sriram
Ch-sriram / wesGpaAutomate.js
Last active July 26, 2023 00:43
WES iGPA Automated Score Filler And Calculator
/*
Paste the methods below in Chrome Console (Ctrl + Shift + I), and then convert the data into JSON string using:
JSON.stringify(data);
Paste that string as a parameter to `prefillSubjectsAndGrades` method.
Example is given at the end of this file.
NOTE: If the fields change (their `id` values in particular), then the algorithm will break, and is rendered useless.
*/
@Ch-sriram
Ch-sriram / circular_q_global.c
Last active February 26, 2022 07:44
Global Circular Queue Implementation in C
#include <stdio.h>
#include <stdlib.h>
static int front = 0;
static int rear = 0;
static int capacity = 2;
static int* q;
void enq(int element) {
@Ch-sriram
Ch-sriram / area-container-max.cpp
Last active November 1, 2020 19:51
Area of Container with the Most Amount of Water [TC: O(N); SC: O(N)]
// Problem Link: https://i.ibb.co/hVT71cp/Container-with-most-water.png
// Test Link: https://ide.geeksforgeeks.org/OBtxHYttjP
// Solution Status: Could not find this particular problem anywhere on any online judge
#include <stack>
#include <vector>
#include <climits>
#include <iostream>
#include <algorithm>
using namespace std;
@Ch-sriram
Ch-sriram / 3sum-closest.cpp
Last active November 1, 2020 13:07
3Sum Closest [TC: O(N^2); SC: O(1)]
// Problem Link: https://leetcode.com/problems/3sum-closest/
// Test Link: https://ide.geeksforgeeks.org/EBNEOuStvx
// Solution Status: Accepted in Leetcode Online Judge
class Solution {
public:
// Approach: Two-Pointer Technique. Time Complexity: Quadratic O(N^2) -- because we fix one element, and for
// the remaining elements, we apply two-ptr technique.
int threeSumClosest(vector<int>& nums, int target) {
sort(nums.begin(), nums.end()); // sort the array to apply two-ptr technique
@Ch-sriram
Ch-sriram / cycle-undirected-dfs.cpp
Last active May 9, 2024 04:59
Detect Cycle in an Undirected Graph [TC: O(V+E); SC: O(V)]
// Problem Link: https://practice.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1/
// Solution Status: Accepted by GFG Judge
/**
* GYTWrkz Solutions Interview Question
* ------------------------------------
* Question 1: Given an Undirected Graph, find whether the Graph has a Cycle or Not (Discussed the approach with the interviewer).
*/
#include <iostream>
@Ch-sriram
Ch-sriram / forest-graph-or-not.cpp
Created October 31, 2020 22:36
Check if Graph is Forest or Not [TC: O(V+E); SC: O(V)]
// Forest Definition: Disjoint Union of Acyclic Graphs (or Trees)
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
bool DFSRec(vector<int> *G, vector<bool> &visited, int curr, int parent) {
visited[curr] = true;
for(int adj: G[curr]) {
if(!visited[adj]) {
@Ch-sriram
Ch-sriram / path-in-graph.cpp
Created October 31, 2020 21:46
Path in a Graph
// Check if there exists a Path from given vertices: (u, v)
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
bool DFSRec(vector<int> *G, int src, int dest, vector<bool> &visited) {
if(src == dest) return true;
visited[src] = true;
for(int u: G[src])
@Ch-sriram
Ch-sriram / dfs-graph.cpp
Created October 31, 2020 20:25
DFS of Graph [TC: O(V+E); SC: O(V)]
// Problem Link: https://practice.geeksforgeeks.org/problems/depth-first-traversal-for-a-graph/1/
#include <iostream>
#include <vector>
using namespace std;
void DFSRec(vector<int> *G, int s, vector<bool> &visited, vector<int> &vertices) {
visited[s] = true;
vertices.push_back(s);
for(int v: G[s])