Skip to content

Instantly share code, notes, and snippets.

View dsapandora's full-sized avatar
🏠
Working from home

Ariel Vernaza dsapandora

🏠
Working from home
View GitHub Profile
@dsapandora
dsapandora / version.cpp
Created April 6, 2020 04:45
Lowest Common Ancestor in a Binary Tree
/* C++ program to find LCA of n1 and n2 using one traversal of Binary Tree.
It handles all cases even when n1 or n2 is not there in Binary Tree */
#include <iostream>
using namespace std;
// A Binary Tree Node
struct Node
{
struct Node *left, *right;
int key;
@dsapandora
dsapandora / version.cpp
Created April 6, 2020 04:24
Convert a given Binary Tree to Doubly Linked List. Given a Binary Tree (BT), convert it to a Doubly Linked List(DLL) In-Place. The left and right pointers in nodes are to be used as previous and next pointers respectively in converted DLL. The order of nodes in DLL must be same as Inorder of the given Binary Tree. The first node of Inorder trave…
# Python3 program to convert a given Binary
# Tree to Doubly Linked List
class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
class BinaryTree:
root, head = None, None
@dsapandora
dsapandora / version.cpp
Last active April 6, 2020 04:21
Pythagorean Triplet in an array. Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2 + b2 = c2.
// A C++ program that returns true if there is a Pythagorean
// Triplet in a given array.
#include <algorithm>
#include <iostream>
using namespace std;
// Returns true if there is a triplet with following property
// A[i]*A[i] = A[j]*A[j] + A[k]*[k]
// Note that this function modifies given array
@dsapandora
dsapandora / same_but_in_python.py
Last active April 8, 2020 06:30
k largest(or smallest) elements in an array
// C++ code for k largest elements in an array
#include <bits/stdc++.h>
using namespace std;
void kLargest(int arr[], int n, int k)
{
// Sort the given array arr in reverse
// order.
sort(arr, arr + n, greater<int>());
# Schedule Library imported
import schedule
import time
# Functions setup
def sudo_placement():
print("Get ready for Sudo Placement")
def good_luck():
print("Good Luck for Test")
class DSASelectionObserver < Sketchup::SelectionObserver
attr_accessor :distance
attr_accessor :count
attr_accessor :model
def initialize(model)
@distance = 0.15
@count = 0
@model = model
end
require 'sketchup.rb'
# unknown origin or usage rights...
module BR_push_pull
def BR_push_pull.main
model = Sketchup.active_model
selection = model.selection
@dsapandora
dsapandora / game_animator.cs
Created January 6, 2019 21:18
Create gameanimator for RPG Action with code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
public class game_animator : MonoBehaviour {
[MenuItem("DSALAB/Create Controller")]
static void CreateController()
#!/bin/bash
head -2 $1 | tail -1 > $1_oneline
filesize=$(du -b $1 | cut -f -1)
linesize=$(du -b $1_oneline | cut -f -1)
rm $1_oneline
echo $(expr $filesize / $linesize)
a=1
for i in *.jpg; do
new=$(printf "%04d.jpg" "$a") #04 pad to length of 4
mv -i -- "$i" "$new"
let a=a+1
done