Skip to content

Instantly share code, notes, and snippets.

View heysujal's full-sized avatar
🎯
Focusing

Sujal Gupta heysujal

🎯
Focusing
View GitHub Profile
@heysujal
heysujal / iterative_boundary_traversal.cpp
Created August 24, 2023 10:50
Iterative Boundary Level Traversal of Binary tree
class Solution {
public:
bool isLeaf(Node* root){
return !root->left and !root->right;
}
void addLeftBoundary(Node* root, vector<int> &ans){
Node* curr = root->left;
while(curr){
if(!isLeaf(curr)) ans.push_back(curr->data);
if(curr->left) curr = curr->left;
@heysujal
heysujal / recursive_boundary.cpp
Last active August 24, 2023 10:52
Iterative Recursive Boundary Level Traversal of Binary Tree
class Solution {
public:
void traverseLeft(Node* root, vector<int> &ans){
if(!root or (!root->left and !root->right)) return;
ans.push_back(root->data);
if(root->left) traverseLeft(root->left, ans);
else traverseLeft(root->right, ans);
}
void traverseLeaf(Node* root, vector<int> &ans){
@heysujal
heysujal / htmlFormToGoogleSheets.js
Created August 12, 2023 09:28
Save html fom data to google sheets directly without using App Scripts.
const regForm = document.querySelector("#regForm");
regForm.addEventListener("submit", () => {
event.preventDefault();
const fullName = document.querySelector("#fullName");
const email = document.querySelector("#email");
const phone = document.querySelector("#phone");
const qual = document.querySelector("#qual");
const state = document.querySelector("#state");
const city = document.querySelector("#city");
const district = document.querySelector("#district");