Snippets Collections
#include "DHT.h"

#define DHTPIN 2  // GPIO Pin D4  

#define DHTTYPE DHT11

// DHT Class dht Object with parameters - assigned Pin and DHt Type

DHT dht(DHTPIN, DHTTYPE);

void setup() {

  // Begin - start communicating with monitor - with Baud rate 9600 serial commn

  Serial.begin(9600);

  // Display test message 

  Serial.println(F("DHTxx test!"));

  dht.begin();

}

void loop() {

  

// 2000 ms - 2 Sec gap for display 

  delay(2000);

  // Read humidity and put in h

  float h = dht.readHumidity();

    // read temperature and put in t in clecius , if nothing in brackets default -False indicating Celcius

  float t = dht.readTemperature();

  // Read temperature as Fahrenheit (isFahrenheit = true)

  //read temperature and put in f in clecius , if true in brackets default -False is overwritten  indicating farenheit

  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).

  if (isnan(h) || isnan(t) || isnan(f)) {

    Serial.println(F("Failed to read from DHT sensor!"));

    return;

  }

  Serial.print(F("Humidity: "));

  Serial.print(h);

  Serial.print(F("%  Temperature: "));

  Serial.print(t);

  Serial.print(F("°C "));

  Serial.print(f);

  Serial.print(F("°F "));

  Serial.println(" ");

}

int Led Pin =2;    // D4 Pin also refereed as pin no2 in Node MCU 

void setup() 

{   

    pinMode(LedPin, OUTPUT);

    Serial.begin(9600);   

}

void loop() {

digitalWrite(LedPin, HIGH); 

delay(1000); 

digitalWrite(LedPin, LOW); 

delay(1000);              

}

int trig=12;     // GPIO Pin D6

int echo=14;     //GPIO Pin D5

int time_microsec;

int time_ms;

int dist_cm;

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);

  pinMode(12,OUTPUT);

  pinMode(14,INPUT);

}

void loop() {

  // put your main code here, to run repeatedly:

digitalWrite(trig,LOW);

delayMicroseconds(2);

digitalWrite(trig,HIGH);

delayMicroseconds(10);

digitalWrite(trig,LOW);

//pulseIn gives time in micro seconds, 1Sec= 1000000 microseconds

time_microsec= pulseIn(echo,HIGH);

time_ms=time_microsec/1000;

dist_cm= (34*time_ms)/2;

Serial.print("Time to travel: ");

Serial.println(time_ms,1);

Serial.print("ms / ");

Serial.print("Distance: ");

Serial.print(dist_cm,1);

Serial.print("cm ");

delay(2000);

DIAGRAM
#include "DHT.h"

#define DHTPIN 2 

#define DHTTYPE DHT11

// DHT Class dht Object with parameters - assigned Pin and DHt Type

DHT dht(DHTPIN, DHTTYPE);

void setup() {

  // Begin - start communicating with monitor - with Baud rate 9600 serial commn

  Serial.begin(9600);

  // Display test message 

  Serial.println(F("DHTxx test!"));

  dht.begin();

}

void loop() {

  

// 2000 ms - 2 Sec gap for display 

  delay(2000);

  // Read humidity and put in h

  float h = dht.readHumidity();

    // read temperature and put in t in clecius , if nothing in brackets default -False indicating Celcius

  float t = dht.readTemperature();

  // Read temperature as Fahrenheit (isFahrenheit = true)

  //read temperature and put in f in clecius , if true in brackets default -False is overwritten  indicating farenheit

  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).

  if (isnan(h) || isnan(t) || isnan(f)) {

    Serial.println(F("Failed to read from DHT sensor!"));

    return;

  }

  Serial.print(F("Humidity: "));

  Serial.print(h);

  Serial.print(F("%  Temperature: "));

  Serial.print(t);

  Serial.print(F("°C "));

  Serial.print(f);

  Serial.print(F("°F "));

  Serial.println(" ");

}
void setup() 

     {  // initialize digital pin LED_BUILTIN as an output.           	

         pinMode(LED_BUILTIN, OUTPUT);

      }

void loop() {  

     digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on

            delay(1000);   // wait for a second 

     digitalWrite(LED_BUILTIN, LOW);   // turn the LED off

            delay(1000);   // wait for a second

}

DIAGRAM
int trig=12;

int echo=11;

int time_microsec;

int time_ms;

int dist_cm;

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);

  pinMode(12,OUTPUT);

  pinMode(11,INPUT);

}

void loop() {

  // put your main code here, to run repeatedly:

digitalWrite(trig,LOW);

delayMicroseconds(2);

digitalWrite(trig,HIGH);

delayMicroseconds(10);

digitalWrite(trig,LOW);

//pulseIn gives time in micro seconds, 1Sec= 1000000 microseconds

time_microsec= pulseIn(echo,HIGH);

time_ms=time_microsec/1000;

dist_cm= (34*time_ms)/2;

Serial.print("Time to travel: ");

Serial.println(time_ms,1);

Serial.print("ms / ");

Serial.print("Distance: ");

Serial.print(dist_cm,1);

Serial.print("cm ");

delay(2000);

}
int trig=12;
int echo=11;
float duration,dist_cm,dist_in;
void setup() {
  // put your setup code here, to run once:
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  Serial.begin(9600);
}

void loop() {
    // put your main code here, to run repeatedly:
    digitalWrite(trig,LOW);
    delayMicroseconds(2);
    digitalWrite(trig,HIGH);
    delayMicroseconds(10);
    digitalWrite(trig,LOW);
    
    duration=pulseIn(echo,HIGH);
    dist_cm=duration*0.0343/2.0;
    dist_in=duration*0.0315/2.0;
    Serial.print("Distance : ");
    Serial.print(dist_cm);
    Serial.print("cm/");
    Serial.print(dist_in);
    Serial.print("inches\n");
    delay(300);
}
#include "DHT.h"
 
#define DHTPIN 2  // GPIO Pin D4  
#define DHTTYPE DHT11
 
// DHT Class dht Object with parameters - assigned Pin and DHt Type
DHT dht(DHTPIN, DHTTYPE);
void setup() {
  // Begin - start communicating with monitor - with Baud rate 9600 serial commn
  Serial.begin(9600);
 
  // Display test message 
  Serial.println(F("DHTxx test!"));
  dht.begin();
}
 
void loop() {
  
// 2000 ms - 2 Sec gap for display 
  delay(2000);
 
  // Read humidity and put in h
  float h = dht.readHumidity();
    // read temperature and put in t in clecius , if nothing in brackets default -False indicating Celcius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  //read temperature and put in f in clecius , if true in brackets default -False is overwritten  indicating farenheit
  float f = dht.readTemperature(true);
 
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
 
  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
  Serial.print(F("°F "));
 
  Serial.println(" ");
}
int Led Pin =2;    // D4 Pin also refereed as pin no2 in Node MCU 
void setup() 
{   
    pinMode(LedPin, OUTPUT);
    Serial.begin(9600);   
}
void loop() {
digitalWrite(LedPin, HIGH); 
delay(1000); 
digitalWrite(LedPin, LOW); 
delay(1000);              
}
void setup() 
     {  // initialize digital pin LED_BUILTIN as an output.           	
         pinMode(LED_BUILTIN, OUTPUT);
      }
void loop() {  
     digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on
            delay(1000);   // wait for a second 
     digitalWrite(LED_BUILTIN, LOW);   // turn the LED off
            delay(1000);   // wait for a second
}
public class GenericsInJava
{
static void processElements(ArrayList<? extends Number> a)
{
for (Object element : a)
{
System.out.println(element);
}
}

public static void main(String[] args)
{
//ArrayList Containing Integers

ArrayList<Integer> a1 = new ArrayList<>();

a1.add(10);

a1.add(20);

a1.add(30);

processElements(a1);

//Arraylist containing Doubles

ArrayList<Double> a2 = new ArrayList<>();

a2.add(21.35);

a2.add(56.47);

a2.add(78.12);

processElements(a2);

//Arraylist containing Strings

ArrayList<String> a3 = new ArrayList<>();

a3.add("One");

a3.add("Two");

a3.add("Three");

//This will not work

processElements(a3);     //Compile time error
}
}
@FunctionalInterface
interface StringReverser {
    String reverse(String str);
}

public class StringReverseLambda {
    public static void main(String[] args) {
        // Lambda expression to reverse a string
        StringReverser reverser = (str) -> new StringBuilder(str).reverse().toString();

        // Example string
        String input = "Hello, World!";
        
        // Reverse the string and print the result
        String reversed = reverser.reverse(input);
        System.out.println("Original: " + input);
        System.out.println("Reversed: " + reversed);
    }
}
import java.util.LinkedList;

class GenericStack<T> {
    private LinkedList<T> stack;

    // Constructor
    public GenericStack() {
        stack = new LinkedList<>();
    }

    // Push method to add an element to the stack
    public void push(T value) {
        stack.addFirst(value);
    }

    // Pop method to remove and return the top element of the stack
    public T pop() {
        if (isEmpty()) {
            throw new IllegalStateException("Stack is empty");
        }
        return stack.removeFirst();
    }

    // Peek method to return the top element without removing it
    public T peek() {
        if (isEmpty()) {
            throw new IllegalStateException("Stack is empty");
        }
        return stack.getFirst();
    }

    // Check if the stack is empty
    public boolean isEmpty() {
        return stack.isEmpty();
    }

    // Get the size of the stack
    public int size() {
        return stack.size();
    }
}

public class GenericStackDemo {
    public static void main(String[] args) {
        // Integer stack
        GenericStack<Integer> intStack = new GenericStack<>();
        intStack.push(1);
        intStack.push(2);
        intStack.push(3);
        System.out.println("Top of Integer stack: " + intStack.peek());
        System.out.println("Pop from Integer stack: " + intStack.pop());
        System.out.println("Size of Integer stack: " + intStack.size());

        // Double stack
        GenericStack<Double> doubleStack = new GenericStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        doubleStack.push(3.3);
        System.out.println("Top of Double stack: " + doubleStack.peek());
        System.out.println("Pop from Double stack: " + doubleStack.pop());
        System.out.println("Size of Double stack: " + doubleStack.size());

        // String stack
        GenericStack<String> stringStack = new GenericStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println("Top of String stack: " + stringStack.peek());
        System.out.println("Pop from String stack: " + stringStack.pop());
        System.out.println("Size of String stack: " + stringStack.size());
    }
}
import java.util.ArrayList;

class GenericStack<T> {
    private ArrayList<T> stack;

    // Constructor
    public GenericStack() {
        stack = new ArrayList<>();
    }

    // Push method to add an element to the stack
    public void push(T value) {
        stack.add(value);
    }

    // Pop method to remove and return the top element of the stack
    public T pop() {
        if (isEmpty()) {
            throw new IllegalStateException("Stack is empty");
        }
        return stack.remove(stack.size() - 1);
    }

    // Peek method to return the top element without removing it
    public T peek() {
        if (isEmpty()) {
            throw new IllegalStateException("Stack is empty");
        }
        return stack.get(stack.size() - 1);
    }

    // Check if the stack is empty
    public boolean isEmpty() {
        return stack.isEmpty();
    }

    // Get the size of the stack
    public int size() {
        return stack.size();
    }
}

public class GenericStackDemo {
    public static void main(String[] args) {
        // Integer stack
        GenericStack<Integer> intStack = new GenericStack<>();
        intStack.push(1);
        intStack.push(2);
        intStack.push(3);
        System.out.println("Top of Integer stack: " + intStack.peek());
        System.out.println("Pop from Integer stack: " + intStack.pop());
        System.out.println("Size of Integer stack: " + intStack.size());

        // Double stack
        GenericStack<Double> doubleStack = new GenericStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        doubleStack.push(3.3);
        System.out.println("Top of Double stack: " + doubleStack.peek());
        System.out.println("Pop from Double stack: " + doubleStack.pop());
        System.out.println("Size of Double stack: " + doubleStack.size());

        // String stack
        GenericStack<String> stringStack = new GenericStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println("Top of String stack: " + stringStack.peek());
        System.out.println("Pop from String stack: " + stringStack.pop());
        System.out.println("Size of String stack: " + stringStack.size());
    }
}
import java.util.ArrayList;

class GenericQueue<T> {
    private ArrayList<T> queue;

    // Constructor
    public GenericQueue() {
        queue = new ArrayList<>();
    }

    // Enqueue method to add an element to the end of the queue
    public void enqueue(T value) {
        queue.add(value);
    }

    // Dequeue method to remove and return the front element of the queue
    public T dequeue() {
        if (isEmpty()) {
            throw new IllegalStateException("Queue is empty");
        }
        return queue.remove(0);
    }

    // Peek method to return the front element without removing it
    public T peek() {
        if (isEmpty()) {
            throw new IllegalStateException("Queue is empty");
        }
        return queue.get(0);
    }

    // Check if the queue is empty
    public boolean isEmpty() {
        return queue.isEmpty();
    }

    // Get the size of the queue
    public int size() {
        return queue.size();
    }
}

public class GenericQueueDemo {
    public static void main(String[] args) {
        // Integer queue
        GenericQueue<Integer> intQueue = new GenericQueue<>();
        intQueue.enqueue(1);
        intQueue.enqueue(2);
        intQueue.enqueue(3);
        System.out.println("Front of Integer queue: " + intQueue.peek());
        System.out.println("Dequeue from Integer queue: " + intQueue.dequeue());
        System.out.println("Size of Integer queue: " + intQueue.size());

        // Double queue
        GenericQueue<Double> doubleQueue = new GenericQueue<>();
        doubleQueue.enqueue(1.1);
        doubleQueue.enqueue(2.2);
        doubleQueue.enqueue(3.3);
        System.out.println("Front of Double queue: " + doubleQueue.peek());
        System.out.println("Dequeue from Double queue: " + doubleQueue.dequeue());
        System.out.println("Size of Double queue: " + doubleQueue.size());

        // String queue
        GenericQueue<String> stringQueue = new GenericQueue<>();
        stringQueue.enqueue("Hello");
        stringQueue.enqueue("World");
        System.out.println("Front of String queue: " + stringQueue.peek());
        System.out.println("Dequeue from String queue: " + stringQueue.dequeue());
        System.out.println("Size of String queue: " + stringQueue.size());
    }
}
@FunctionalInterface
interface PiProvider {
    double getPi();
}

public class PiLambda {
    public static void main(String[] args) {
        // Lambda expression to return the value of Pi
        PiProvider piProvider = () -> Math.PI;
        
        // Invoke the lambda expression and print the value of Pi
        double piValue = piProvider.getPi();
        System.out.println("The value of Pi is: " + piValue);
    }
}
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.TreeMap;
import java.util.Map;

public class CollectionDemo {
    public static void main(String[] args) {
        // HashMap demonstration
        System.out.println("HashMap:");
        Map<String, Integer> hashMap = new HashMap<>();
        hashMap.put("Alice", 25);
        hashMap.put("Bob", 30);
        hashMap.put("Charlie", 35);
        for (Map.Entry<String, Integer> entry : hashMap.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }

        // LinkedHashMap demonstration
        System.out.println("\nLinkedHashMap:");
        Map<String, Integer> linkedHashMap = new LinkedHashMap<>();
        linkedHashMap.put("Alice", 25);
        linkedHashMap.put("Bob", 30);
        linkedHashMap.put("Charlie", 35);
        for (Map.Entry<String, Integer> entry : linkedHashMap.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }

        // TreeMap demonstration
        System.out.println("\nTreeMap:");
        Map<String, Integer> treeMap = new TreeMap<>();
        treeMap.put("Alice", 25);
        treeMap.put("Bob", 30);
        treeMap.put("Charlie", 35);
        for (Map.Entry<String, Integer> entry : treeMap.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class IteratorExample {
    public static void main(String[] args) {
        // Create an ArrayList and add some elements
        List<String> arrayList = new ArrayList<>();
        arrayList.add("Apple");
        arrayList.add("Banana");
        arrayList.add("Cherry");

        // Create a LinkedList and add some elements
        List<String> linkedList = new LinkedList<>();
        linkedList.add("Dog");
        linkedList.add("Elephant");
        linkedList.add("Frog");

        // Iterate over the ArrayList
        System.out.println("ArrayList elements:");
        Iterator<String> arrayListIterator = arrayList.iterator();
        while (arrayListIterator.hasNext()) {
            String element = arrayListIterator.next();
            System.out.println(element);
        }

        // Iterate over the LinkedList
        System.out.println("\nLinkedList elements:");
        Iterator<String> linkedListIterator = linkedList.iterator();
        while (linkedListIterator.hasNext()) {
            String element = linkedListIterator.next();
            System.out.println(element);
        }
    }
}
class ArrayStack<T> {
    private T[] array;
    private int top;
    private int capacity;

    // Constructor
    @SuppressWarnings("unchecked")
    public ArrayStack(int capacity) {
        this.capacity = capacity;
        this.array = (T[]) new Object[capacity]; // Create a generic array
        this.top = -1;
    }

    // Push method
    public void push(T value) {
        if (top == capacity - 1) {
            throw new StackOverflowError("Stack is full");
        }
        array[++top] = value;
    }

    // Pop method
    public T pop() {
        if (top == -1) {
            throw new IllegalStateException("Stack is empty");
        }
        return array[top--];
    }

    // Peek method
    public T peek() {
        if (top == -1) {
            throw new IllegalStateException("Stack is empty");
        }
        return array[top];
    }

    // Check if stack is empty
    public boolean isEmpty() {
        return top == -1;
    }

    // Check if stack is full
    public boolean isFull() {
        return top == capacity - 1;
    }
}

public class ArrayStackDemo {
    public static void main(String[] args) {
        ArrayStack<Integer> intStack = new ArrayStack<>(5);
        intStack.push(1);
        intStack.push(2);
        intStack.push(3);
        System.out.println("Top of Integer stack: " + intStack.peek());
        System.out.println("Pop from Integer stack: " + intStack.pop());

        ArrayStack<Double> doubleStack = new ArrayStack<>(5);
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        doubleStack.push(3.3);
        System.out.println("Top of Double stack: " + doubleStack.peek());
        System.out.println("Pop from Double stack: " + doubleStack.pop());

        ArrayStack<String> stringStack = new ArrayStack<>(5);
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println("Top of String stack: " + stringStack.peek());
        System.out.println("Pop from String stack: " + stringStack.pop());
    }
}









class LinkedListStack<T> {
    private static class Node<T> {
        private T data;
        private Node<T> next;

        public Node(T data) {
            this.data = data;
        }
    }

    private Node<T> top;

    // Push method
    public void push(T value) {
        Node<T> newNode = new Node<>(value);
        newNode.next = top;
        top = newNode;
    }

    // Pop method
    public T pop() {
        if (top == null) {
            throw new IllegalStateException("Stack is empty");
        }
        T value = top.data;
        top = top.next;
        return value;
    }

    // Peek method
    public T peek() {
        if (top == null) {
            throw new IllegalStateException("Stack is empty");
        }
        return top.data;
    }

    // Check if stack is empty
    public boolean isEmpty() {
        return top == null;
    }
}

public class LinkedListStackDemo {
    public static void main(String[] args) {
        LinkedListStack<Integer> intStack = new LinkedListStack<>();
        intStack.push(1);
        intStack.push(2);
        intStack.push(3);
        System.out.println("Top of Integer stack: " + intStack.peek());
        System.out.println("Pop from Integer stack: " + intStack.pop());

        LinkedListStack<Double> doubleStack = new LinkedListStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        doubleStack.push(3.3);
        System.out.println("Top of Double stack: " + doubleStack.peek());
        System.out.println("Pop from Double stack: " + doubleStack.pop());

        LinkedListStack<String> stringStack = new LinkedListStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println("Top of String stack: " + stringStack.peek());
        System.out.println("Pop from String stack: " + stringStack.pop());
    }
}
public class p5b {
    static class LinkedListQueue<T> {
        private class Node<T> {
            private T data;
            private Node<T> next;

            Node(T data) {
                this.data = data;
            }
        }

        private Node<T> front, rear;

        void enqueue(T item) {
            Node<T> newNode = new Node<>(item);
            if (tail == null)
                front = rear = newNode;
            else {
                rear.next = newNode;
                rear = newNode;
            }
        }

        T dequeue() {
            if (front == null)
                System.out.println("Queue is empty");
            T data = front.data;
            front = front.next;
            if (front == null)
                rear = null;
            return data;
        }
    }

    static class ArrayQueue<T> {
        private T[] array;
        private int front, rear, capacity;

        @SuppressWarnings("unchecked")
        ArrayQueue(int size) {
            capacity = size;
            array = (T[]) new Object[capacity];
        }

        void enqueue(T item) {
            if ((rear + 1) % capacity == front)
                System.out.println("Queue is full");
            array[rear] = item;
            rear = (rear + 1) % capacity;
        }

        T dequeue() {
            if (front == rear)
                System.out.println("Queue is empty");
            T item = array[front];
            front = (front + 1) % capacity;
            return item;
        }
    }

    public static void main(String[] args) {
        ArrayQueue<Integer> intQueue = new ArrayQueue<>(5);
        intQueue.enqueue(10);
        intQueue.enqueue(20);
        System.out.println(intQueue.dequeue());
        System.out.println(intQueue.dequeue());
        LinkedListQueue<String> stringQueue = new LinkedListQueue<>();
        stringQueue.enqueue("Hello");
        stringQueue.enqueue("World");
        System.out.println(stringQueue.dequeue());
    }
}
import java.util.TreeSet;
class TreeNode{
    int value;
    TreeNode right,left;
    TreeNode(int a){
        value=a;
    }
}
class BSTTest{
    TreeNode root;
    void insert(int value)
    {
        root=insertNode(root,value);
    }
    TreeNode insertNode(TreeNode root,int value)
    {
        if(root==null)
            return new TreeNode(value);
        if(root.value>value)
            root.left=insertNode(root.left,value);
        else if(root.value<value)
            root.right=insertNode(root.right,value);
        return root;
    }
    void inorder(){
        inorderNodes(root);
        System.out.println(" ");
    }
    void inorderNodes(TreeNode root)
    {
        if(root!=null)
        {
            inorderNodes(root.left);
            System.out.print(root.value+" ");
            inorderNodes(root.right);
        }
    }
    void preorder(){
        preorderNodes(root);
        System.out.println(" ");
    }
    void preorderNodes(TreeNode root)
    {
        if(root!=null)
        {
            System.out.print(root.value+" ");
            preorderNodes(root.left);
            preorderNodes(root.right);
        }
    }
    void postorder(){
        postorderNodes(root);
        System.out.println(" ");
    }
    void postorderNodes(TreeNode root)
    {
        if(root!=null)
        {
            postorderNodes(root.left);
            postorderNodes(root.right);
            System.out.print(root.value+" ");
        }
    }
    public static void main(String[] args)
    {
        BSTTest tree = new BSTTest();
        TreeSet ts=new TreeSet();
        int[] values={10,58,42,63,15,0,42,14};
        for(int a:values)
        {
            tree.insert(a);
            ts.add(a);
        }
        System.out.println("Inorder traversals");
        tree.inorder();
        System.out.println("preorder traversals");
        tree.preorder();
        System.out.println("postorder traversals");
        tree.postorder();
    }
}
class Demo<K extends Comparable<K>, V> {
    private class Node {
        K key;
        V value;
        int height;
        Node left, right;

        Node(K key, V value) {
            this.key = key;
            this.value = value;
            this.height = 1;
        }
    }

    private Node root;

    // Utility function to get the height of the tree
    private int height(Node node) {
        if (node == null) return 0;
        return node.height;
    }

    // Utility function to get the maximum of two integers
    private int max(int a, int b) {
        return (a > b) ? a : b;
    }

    // Right rotate subtree rooted with y
    private Node rightRotate(Node y) {
        Node x = y.left;
        Node T2 = x.right;

        // Perform rotation
        x.right = y;
        y.left = T2;

        // Update heights
        y.height = max(height(y.left), height(y.right)) + 1;
        x.height = max(height(x.left), height(x.right)) + 1;

        // Return new root
        return x;
    }

    // Left rotate subtree rooted with x
    private Node leftRotate(Node x) {
        Node y = x.right;
        Node T2 = y.left;

        // Perform rotation
        y.left = x;
        x.right = T2;

        // Update heights
        x.height = max(height(x.left), height(x.right)) + 1;
        y.height = max(height(y.left), height(y.right)) + 1;

        // Return new root
        return y;
    }

    // Get balance factor of node
    private int getBalance(Node node) {
        if (node == null) return 0;
        return height(node.left) - height(node.right);
    }

    // Insert a node
    public void insert(K key, V value) {
        root = insertNode(root, key, value);
    }

    private Node insertNode(Node node, K key, V value) {
        // 1. Perform the normal BST insertion
        if (node == null) return new Node(key, value);

        if (key.compareTo(node.key) < 0) {
            node.left = insertNode(node.left, key, value);
        } else if (key.compareTo(node.key) > 0) {
            node.right = insertNode(node.right, key, value);
        } else {
            // Duplicate keys are not allowed
            return node;
        }

        // 2. Update height of this ancestor node
        node.height = 1 + max(height(node.left), height(node.right));

        // 3. Get the balance factor of this ancestor node to check whether this node became unbalanced
        int balance = getBalance(node);

        // If this node becomes unbalanced, then there are 4 cases

        // Left Left Case
        if (balance > 1 && key.compareTo(node.left.key) < 0) {
            return rightRotate(node);
        }

        // Right Right Case
        if (balance < -1 && key.compareTo(node.right.key) > 0) {
            return leftRotate(node);
        }

        // Left Right Case
        if (balance > 1 && key.compareTo(node.left.key) > 0) {
            node.left = leftRotate(node.left);
            return rightRotate(node);
        }

        // Right Left Case
        if (balance < -1 && key.compareTo(node.right.key) < 0) {
            node.right = rightRotate(node.right);
            return leftRotate(node);
        }

        // Return the (unchanged) node pointer
        return node;
    }

    // Method to print tree in order
    public void inorder() {
        inorderRec(root);
    }

    private void inorderRec(Node root) {
        if (root != null) {
            inorderRec(root.left);
            System.out.print(root.key + " ");
            inorderRec(root.right);
        }
    }

    public static void main(String[] args) {
        Demo<Integer, String> tree = new Demo<>();

        /* Constructing tree given in the above figure */
        tree.insert(9, "Nine");
        tree.insert(5, "Five");
        tree.insert(10, "Ten");
        tree.insert(0, "Zero");
        tree.insert(6, "Six");
        tree.insert(11, "Eleven");
        tree.insert(-1, "Minus One");
        tree.insert(1, "One");
        tree.insert(2, "Two");

        

        System.out.println("Inorder traversal of the constructed AVL tree is:");
        tree.inorder();

        /* The AVL Tree after deletion of 10
                 1
                /  \
               0    9
             /     /  \
           -1     5     11
                /  \
               2    6
        */
    }
}
import java.util.*;
import java.util.stream.Collectors;

class Product {
    int id;
    String name;
    double price;
    String type;
    double rating;

    Product(int id, String name, double price, String type, double rating) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.type = type;
        this.rating = rating;
    }

    public String toString() {
        return name + " (Price: " + price + ", Type: " + type + ", Rating: " + rating + ")";
    }
}

public class p11 {
    public static void main(String[] args) {
        List<Product> products = Arrays.asList(
                new Product(1, "Laptop", 1500.0, "Electronics", 4.5),
                new Product(2, "Smartphone", 800.0, "Electronics", 4.8),
                new Product(3, "Refrigerator", 2000.0, "Home Appliances", 4.2),
                new Product(4, "TV", 300.0, "Electronics", 3.9),
                new Product(5, "Blender", 150.0, "Home Appliances", 4.1));

        System.out.println("Products with rating between 4 and 5:");
        products.stream().filter(p -> p.rating >= 4 && p.rating <= 5).forEach(System.out::println);

        System.out.println("\nFirst 2 products with price > 1000:");
        products.stream().filter(p -> p.price > 1000).limit(2).forEach(System.out::println);

        System.out.println("\nNumber of products under each type:");
        products.stream().collect(Collectors.groupingBy(p -> p.type, Collectors.counting()))
                .forEach((type, count) -> System.out.println(type + ": " + count));

        double averageRating = products.stream().filter(p -> p.type.equals("Electronics"))
                .mapToDouble(p -> p.rating).average().orElse(0.0);
        System.out.println("\nAverage rating of Electronics products: " + averageRating);
    }
}
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Person {
    private String name;
    private int age;
    private double income;

    public Person(String name, int age, double income) {
        this.name = name;
        this.age = age;
        this.income = income;
    }

    public int getAge() {
        return age;
    }

    public double getIncome() {
        return income;
    }

    @Override
    public String toString() {
        return "Person{name='" + name + "', age=" + age + ", income=" + income + '}';
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Set<Person> setA = new HashSet<>();
        Set<Person> setB = new HashSet<>();
        Set<Person> setC = new HashSet<>();

        // Reading set A of persons from the user
        System.out.println("Enter the number of persons in set A:");
        int n = scanner.nextInt();
        scanner.nextLine(); // Consume newline
        for (int i = 0; i < n; i++) {
            System.out.println("Enter details for person " + (i + 1) + " (name, age, income):");
            String[] details = scanner.nextLine().split("\\s+");
            String name = details[0];
            int age = Integer.parseInt(details[1]);
            double income = Double.parseDouble(details[2]);
            setA.add(new Person(name, age, income));
        }

        // Computing set B of persons whose age >= 60
        for (Person person : setA) {
            if (person.getAge() >= 60) {
                setB.add(person);
            }
        }

        // Computing set C of persons whose income < 10000
        for (Person person : setA) {
            if (person.getIncome() < 10000) {
                setC.add(person);
            }
        }

        // Computing set B union C
        Set<Person> setBC = new HashSet<>(setB);
        setBC.addAll(setC);

        // Printing the computed sets
        System.out.println("\nSet B (Persons aged 60 or above):");
        printSet(setB);
        System.out.println("\nSet C (Persons with income < 10000):");
        printSet(setC);
        System.out.println("\nSet B union C:");
        printSet(setBC);
    }

    private static void printSet(Set<Person> set) {
        for (Person person : set) {
            System.out.println(person);
        }
    }
}
// Lưu dữ liệu đã chỉnh sửa vào localStorage
function saveAdData(selector) {
    const element = document.querySelector(selector);
    if (element) {
        const content = element.innerHTML;
        localStorage.setItem('adContent', content);
        alert('Đã lưu dữ liệu chỉnh sửa thành công!');
    } else {
        alert('Không tìm thấy phần tử để lưu dữ liệu.');
int maxSubArray(vector<int>& nums)
{
    int sum=0;
    int maxi = INT_MIN;
    for(int i=0;i<nums.size();++i)
    {   sum+=nums[i];
        maxi = max(maxi,sum);
        if(sum<0)
        sum=0;
    }
    return maxi;
}
  const taskForm = document.querySelector("#task-form");
const inputTask = document.querySelector("#task");
const mainCollection = document.querySelector(".collection");
const clearTask = document.querySelector(".clear-tasks");

// Function to save tasks to local storage
function saveTasksToLocalStorage(tasks) {
    localStorage.setItem('tasks', JSON.stringify(tasks));
}

// Function to load tasks from local storage
function loadTasksFromLocalStorage() {
    const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
    tasks.forEach(function(task) {
        addTaskToList(task);
    });
    return tasks;
}

// Load tasks from local storage when the page loads
let tasks = loadTasksFromLocalStorage();

// Event listener for form submission
taskForm.addEventListener("submit", function(e){
    e.preventDefault();

    const inputValue = inputTask.value.trim();
    if(!inputValue){
        alert("Fill the input field");
        return;
    }

    addTaskToList(inputValue);
    tasks.push(inputValue);
    saveTasksToLocalStorage(tasks);
    inputTask.value = "";
});

// Function to add task to the list
function addTaskToList(taskContent) {
    const liElement = document.createElement("li");
    liElement.className = "collection-item";
    liElement.innerHTML = `
        <span class="task-text">${taskContent}</span>
        <a href="#" class="delete-item secondary-content">
            <i class="fa fa-remove"></i>
        </a>
        <a href="#" class="edit-item secondary-content">
            <i class="fa fa-edit"></i>
        </a>`;
   
    mainCollection.appendChild(liElement);
}

// Event listener for clearing tasks
clearTask.addEventListener("click", function(e){
    e.preventDefault();
    if(confirm("Are You Sure")){
        mainCollection.innerHTML = "";
        tasks = [];
        saveTasksToLocalStorage(tasks);
    }
});

// Event listener for editing and deleting tasks
mainCollection.addEventListener("click", function(e){
    e.preventDefault();
    const currentClickElement = e.target;

    // Editing task
    if (currentClickElement.classList.contains("fa-edit")) {
        const listItem = currentClickElement.parentElement.parentElement;
        const taskTextElement = listItem.querySelector(".task-text");
        const newTaskText = prompt("Edit Task:", taskTextElement.textContent.trim());
        if (newTaskText !== null) {
            taskTextElement.textContent = newTaskText;
            const index = tasks.indexOf(taskTextElement.textContent);
            tasks[index] = newTaskText;
            saveTasksToLocalStorage(tasks);
        }
    }

    // Deleting task
    if(currentClickElement.classList.contains("fa-remove")){
        const listItem = currentClickElement.parentElement.parentElement;
        if(confirm(`Are You Sure You Want To Remove This Task`)){
            listItem.remove();
            const index = tasks.indexOf(listItem.querySelector(".task-text").textContent);
            tasks.splice(index, 1);
            saveTasksToLocalStorage(tasks);
        };
    }
});
int maxSubArray(vector<int>& nums)
 {
    int n=nums.size();
    if(n==1)
    return nums[0];
    vector<int> pf;
    pf.push_back(nums[0]);
    for(int i=1;i<n;++i)
    pf.push_back(nums[i]+pf[i-1]);
    int m = INT_MIN;
    int elem = *max_element(pf.begin(),pf.end());
    for(int j=0;j<n-1;++j)
    {
        for(int k=j+1;k<n;++k)
        m = max(m,(pf[k]-pf[j]));
        
    }
    m = max(m,elem);
    int mi = *max_element(nums.begin(),nums.end());
    cout<<m<<" "<<mi;
    
    if(mi>m)
    return mi;
    else return m;
    

 }
javascript: (function () {
  const input = prompt("input", document.getSelection().toString());
  if (input) {
    const output = input.replace(/[\u0300\u0301]/g, "");
    window.alert(output);
    navigator.clipboard.writeText(output);
  }
})();
1) Hugeivons Pro
2) Boxicons
3) Tablet Icons
4) Font Awesome 
5) Phosphor Icons
6) Iconify
7) Flaticons
8) Lucide.dev
9) Heroicons
10) React-icons
11) Iconbuddy
12) icones.js.org
1. Nodejs & NVM
2. DBeaver
3. Postman
4. Hoppscotch - directly go to website. No package installation required 
5. Git
6. VS Code
7. Neovim
8. ThisCodeWorks PWA for PC
9. Docker Desktop 
10. Pomofocus ---- web app
11. Powertoys for windows
12. Devtoys for windows
13. python - sometimes it is needed for installing other packages in windows
14. Anaconda python version manager
15. Easy window switcher
16. QuickLook
17. Hack-N-Peck
18. WinScp
Node npm packages
1)mysql2
2)multer
3)ejs
4)nodemon
5)body-parser
6)express
7)express-session
8)connect -mongodb-session 
9)bcryptjs for encrypting password in db
10)csurf for prevention of csrf attack 
11)Express validator 
12)Xlsx for reading Excel files
13)Morgan = error logging tool
14)Axios-retry
15)pm2
16)Helmet = for production headers
17)Compression = search nodejs compression or express compression 
18)New Relic and datadog for logging and monitoring 
19)express-rate-limit
20)cookie-parser
21)jsonwebtoken
22)cors
23)dotenv

Dev
@types/bcrypt
@types/cookie-parser
@types/cors
@types/express
@types/jsonwebtoken
rimraf
ts-node-dev
typescript

React
1) Zod = validation library 
2) Tanstack react-query
3) Shadcdn
4) react hook forms
5) cn
6) tailwind prettier
7) luxon = time library
8) mockaroo.com for generating dummy data jason.
9) date-fns or dayJS= dates library 
10)React-leaflet for maps and it needs LEAFLET a js dependency.
11)react-hot-toast = alert notification toast 
12)Sentry = error logging tool
13)react-window
14)googlemaps
15)mapbox
16)deck.gl
17)Turf = geospatial 
19)Radix UI
20)react-redux & @redux/toolkit
21)popper - https://popper.js.org/docs/v2/
22)react-error-boundry


Library for charts
1)Apex charts
2)Apache echarts
3)D3.js
4)recharts
5)chartsjs
6)nivo.rocks - this is built on top of D3JS

YouTube suggestions 
1)Nextdns.io
2)Warp cli ai
3)Tmux
4)Local Https and caddy server
5)Eyedropper api for colour selection 


http://chatbotscriptmanage.dev.com/login

10.240.144.197 staging.chatbot-public.cyberbot.vn
10.240.144.197 staging.chatbot-private.cyberbot.vn

// Banker's Algorithm
#include <stdio.h>
int main()
{
    // P0, P1, P2, P3, P4 are the Process names here

    int n, m, i, j, k;
    n = 5; // Number of processes
    m = 3; // Number of resources
    int alloc[5][3] = { { 0, 1, 0 }, // P0    // Allocation Matrix
                        { 2, 0, 0 }, // P1
                        { 3, 0, 2 }, // P2
                        { 2, 1, 1 }, // P3
                        { 0, 0, 2 } }; // P4

    int max[5][3] = { { 7, 5, 3 }, // P0    // MAX Matrix
                      { 3, 2, 2 }, // P1
                      { 9, 0, 2 }, // P2
                      { 2, 2, 2 }, // P3
                      { 4, 3, 3 } }; // P4

    int avail[3] = { 3, 3, 2 }; // Available Resources

    int f[n], ans[n], ind = 0;
    for (k = 0; k < n; k++) {
        f[k] = 0;
    }
    int need[n][m];
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++)
            need[i][j] = max[i][j] - alloc[i][j];
    }
    int y = 0;
    for (k = 0; k < 5; k++) {
        for (i = 0; i < n; i++) {
            if (f[i] == 0) {

                int flag = 0;
                for (j = 0; j < m; j++) {
                    if (need[i][j] > avail[j]){
                        flag = 1;
                         break;
                    }
                }

                if (flag == 0) {
                    ans[ind++] = i;
                    for (y = 0; y < m; y++)
                        avail[y] += alloc[i][y];
                    f[i] = 1;
                }
            }
        }
    }
  
      int flag = 1;
      
      for(int i=0;i<n;i++)
    {
      if(f[i]==0)
      {
        flag=0;
         printf("The following system is not safe");
        break;
      }
    }
    
      if(flag==1)
    {
      printf("Following is the SAFE Sequence\n");
      for (i = 0; i < n - 1; i++)
        printf(" P%d ->", ans[i]);
      printf(" P%d", ans[n - 1]);
    }
    

    return (0);

    // This code is contributed by Deep Baldha (CandyZack)
}
#include <stdio.h>

int main() {
    int arrival_time[10], burst_time[10], remaining_time[10];
    int i, smallest, count = 0, time, limit;
    double wait_time = 0, turnaround_time = 0, end_time;
    float average_waiting_time, average_turnaround_time;

    printf("Enter the Total Number of Processes: ");
    scanf("%d", &limit);
    
    printf("Enter Details of %d Processes\n", limit);
    for (i = 0; i < limit; i++) {
        printf("Enter Arrival Time for Process %d: ", i + 1);
        scanf("%d", &arrival_time[i]);
        printf("Enter Burst Time for Process %d: ", i + 1);
        scanf("%d", &burst_time[i]);
        remaining_time[i] = burst_time[i];
    }
    
    remaining_time[9] = 9999;  // Sentinel value for comparison

    for (time = 0; count != limit; time++) {
        smallest = 9;
        for (i = 0; i < limit; i++) {
            if (arrival_time[i] <= time && remaining_time[i] < remaining_time[smallest] && remaining_time[i] > 0) {
                smallest = i;
            }
        }

        remaining_time[smallest]--;

        if (remaining_time[smallest] == 0) {
            count++;
            end_time = time + 1;
            wait_time += end_time - arrival_time[smallest] - burst_time[smallest];
            turnaround_time += end_time - arrival_time[smallest];
        }
    }

    average_waiting_time = wait_time / limit;
    average_turnaround_time = turnaround_time / limit;

    printf("\nAverage Waiting Time: %.2lf", average_waiting_time);
    printf("\nAverage Turnaround Time: %.2lf\n", average_turnaround_time);

    return 0;
}
#include <stdio.h>

int main() {
    int bt[20], p[20], wt[20], tat[20], i, j, n, total = 0, pos, temp;
    float avg_wt, avg_tat;

    printf("Enter number of processes: ");
    scanf("%d", &n);

    printf("\nEnter Burst Time:\n");
    for (i = 0; i < n; i++) {
        printf("p%d: ", i + 1);
        scanf("%d", &bt[i]);
        p[i] = i + 1; // Process number
    }

    // Sorting of burst times and process numbers in ascending order
    for (i = 0; i < n; i++) {
        pos = i;
        for (j = i + 1; j < n; j++) {
            if (bt[j] < bt[pos])
                pos = j;
        }

        // Swapping burst time
        temp = bt[i];
        bt[i] = bt[pos];
        bt[pos] = temp;

        // Swapping process number
        temp = p[i];
        p[i] = p[pos];
        p[pos] = temp;
    }

    wt[0] = 0; // Waiting time for the first process is 0

    // Calculating waiting time
    for (i = 1; i < n; i++) {
        wt[i] = 0;
        for (j = 0; j < i; j++)
            wt[i] += bt[j];

        total += wt[i];
    }

    avg_wt = (float) total / n; // Average waiting time
    total = 0;

    printf("\nProcess\t    Burst Time    Waiting Time    Turnaround Time\n");
    for (i = 0; i < n; i++) {
        tat[i] = bt[i] + wt[i]; // Calculating turnaround time
        total += tat[i];
        printf("p%d\t\t  %d\t\t    %d\t\t    %d\n", p[i], bt[i], wt[i], tat[i]);
    }

    avg_tat = (float) total / n; // Average turnaround time
    printf("\nAverage Waiting Time = %.2f", avg_wt);
    printf("\nAverage Turnaround Time = %.2f\n", avg_tat);

    return 0;
}
// Bounded type parameter example
class NumberContainer<T extends Number> {
    private T number;

    public NumberContainer(T number) {
        this.number = number;
    }

    public T getNumber() {
        return number;
    }

    public void setNumber(T number) {
        this.number = number;
    }

    public void display() {
        System.out.println("Number: " + number);
    }
}

// Wildcard argument example
class Utils {
    // Method to display elements of a NumberContainer with wildcard argument
    public static void displayNumberContainer(NumberContainer<?> container) {
        System.out.println("Number in container: " + container.getNumber());
    }
}

public class Main {
    public static void main(String[] args) {
        // Bounded type parameter example
        NumberContainer<Integer> intContainer = new NumberContainer<>(10);
        intContainer.display();

        NumberContainer<Double> doubleContainer = new NumberContainer<>(3.14);
        doubleContainer.display();

        // Wildcard argument example
        Utils.displayNumberContainer(intContainer);
        Utils.displayNumberContainer(doubleContainer);
    }
}
 AVLNode<T extends Comparable<T>> {
    T data;
    AVLNode<T> left, right;
    int height;

    public AVLNode(T data) {
        this.data = data;
        this.left = null;
        this.right = null;
        this.height = 1;
    }
}

public class AVLTree<T extends Comparable<T>> {
    private AVLNode<T> root;

    public AVLTree() {
        this.root = null;
    }

    private int height(AVLNode<T> node) {
        if (node == null) return 0;
        return node.height;
    }

    private int getBalance(AVLNode<T> node) {
        if (node == null) return 0;
        return height(node.left) - height(node.right);
    }

    public AVLNode<T> insert(AVLNode<T> node, T data) {
        if (node == null) return new AVLNode<>(data);

        if (data.compareTo(node.data) < 0) {
            node.left = insert(node.left, data);
        } else if (data.compareTo(node.data) > 0) {
            node.right = insert(node.right, data);
        } else {
            return node; // Duplicate keys not allowed
        }

        // Update height of this ancestor node
        node.height = 1 + Math.max(height(node.left), height(node.right));

        // Get the balance factor and perform rotation if needed
        int balance = getBalance(node);

        // Left Left Case
        if (balance > 1 && data.compareTo(node.left.data) < 0) {
            return rightRotate(node);
        }

        // Right Right Case
        if (balance < -1 && data.compareTo(node.right.data) > 0) {
            return leftRotate(node);
        }

        // Left Right Case
        if (balance > 1 && data.compareTo(node.left.data) > 0) {
            node.left = leftRotate(node.left);
            return rightRotate(node);
        }

        // Right Left Case
        if (balance < -1 && data.compareTo(node.right.data) < 0) {
            node.right = rightRotate(node.right);
            return leftRotate(node);
        }

        return node;
    }

    private AVLNode<T> rightRotate(AVLNode<T> y) {
        AVLNode<T> x = y.left;
        AVLNode<T> T2 = x.right;

        // Perform rotation
        x.right = y;
        y.left = T2;

        // Update heights
        y.height = Math.max(height(y.left), height(y.right)) + 1;
        x.height = Math.max(height(x.left), height(x.right)) + 1;

        return x;
    }

    private AVLNode<T> leftRotate(AVLNode<T> x) {
        AVLNode<T> y = x.right;
        AVLNode<T> T2 = y.left;

        // Perform rotation
        y.left = x;
        x.right = T2;

        // Update heights
        x.height = Math.max(height(x.left), height(x.right)) + 1;
        y.height = Math.max(height(y.left), height(y.right)) + 1;

        return y;
    }

    public void insert(T data) {
        root = insert(root, data);
    }

    public void inorderTraversal() {
        inorderTraversal(root);
        System.out.println();
    }

    private void inorderTraversal(AVLNode<T> node) {
        if (node != null) {
            inorderTraversal(node.left);
            System.out.print(node.data + " ");
            inorderTraversal(node.right);
        }
    }

    public static void main(String[] args) {
        AVLTree<Integer> avlTree = new AVLTree<>();
        avlTree.insert(10);
        avlTree.insert(20);
        avlTree.insert(30);
        avlTree.insert(40);
        avlTree.insert(50);
        avlTree.insert(25);

        System.out.println("Inorder traversal:");
        avlTree.inorderTraversal();
    }
}
--------------------------------------
 vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {
        stack<int> s;
        const int N =1e5;
        vector<int> ans;
        vector<int> v(N);
        int n=nums2.size();
        s.push(nums2[n-1]);
        v[nums2[n-1]]=-1;
        
        for(int i=nums2.size()-2;i>=0;--i)
        {
             if(nums2[i]<(s.top()))
            {
                
                v[nums2[i]]=s.top();
                s.push(nums2[i]);
            }
            else
            {
                while(!s.empty() && s.top()<nums2[i]  )//order matters in &&
                s.pop();
                if(s.empty())
                v[nums2[i]]=-1;
                else
                v[nums2[i]]=s.top();
                s.push(nums2[i]);
            }
        }
        for(int j=0;j<nums1.size();++j)
        {
            ans.push_back(v[nums1[j]]);
        }


        return ans;
    }
   
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <video src="video.mp4" height="255" controls loop muted poster="download.jpg"></video>

    <audio src="sachin.mp3" controls autoplay loop muted></audio>

    <svg height="100" width="100">
        <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
    </svg>
    <img src="img.svg" alt="My Svg Image">

    <!-- <iframe src="https://www.codewithharry.com/tutorial/html-iframes/" width="322" height="444"></iframe> -->
    
    <iframe width="560" height="315" src="https://www.youtube.com/embed/tVzUXW6siu0?si=NuQZuYqrMHn7Pg-i&amp;start=739" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

    <!-- Quick Quiz  -->
    <!-- Create a website which shows videos of different category and audios of different categories.
    You can use YouTube videos in an iframe using YouTube's embedding feature -->
</body>
</html>
Block Elements (Most Commonly Used First)

<div>: A generic container for flow content.
<p>: Paragraph.
<h1>, <h2>, <h3>, <h4>, <h5>, <h6>: Headings.
<ul>: Unordered list.
<ol>: Ordered list.
<li>: List item.
<form>: A section containing form controls.
<table>: Table.
<section>: A standalone section of a document.
<header>: A container for introductory content or a set of navigational links.
<footer>: Footer of a section or page.
<nav>: A section of a page that contains navigation links.
<article>: A self-contained composition in a document.
<aside>: A section of a page that contains information indirectly related to the main content.
<main>: The main content of a document.
<fieldset>: A set of form controls grouped under a common name.
<blockquote>: A block of text that is a quotation from another source.
<pre>: Preformatted text.
<canvas>: A container used to draw graphics via JavaScript.
<dl>: Description list.
<dt>: Term in a description list.
<dd>: Description in a description list.
<figure>: Any content that is referenced from the main content.
<figcaption>: A caption for a <figure> element.
<address>: Contact information for the author or owner of the document.
<hr>: A thematic break or a horizontal rule.
<tfoot>: Footer of a table.



Inline Elements (Most Commonly Used First)
<a>: Anchor or hyperlink.
<img>: Image.
<span>: Generic inline container.
<input>: Input field.
<label>: Label for a form element.
<strong>: Strong emphasis.
<em>: Emphasized text.
<br>: Line break.
<code>: Code snippet.
<b>: Bold text.
<i>: Italic text.
<u>: Underlined text.
<small>: Smaller text.
<sub>: Subscript.
<sup>: Superscript.
<mark>: Marked or highlighted text.
<q>: Short inline quotation.
<cite>: Citation.
<kbd>: Keyboard input.
<samp>: Sample output.
<var>: Variable in a mathematical expression or programming context.
<time>: Time.
<abbr>: Abbreviation.
<data>: Machine-readable translation of content.
<acronym>: Acronym (Not supported in HTML5).
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Inline and Block Elements - HTML</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <p>Hey I am a para</p>
    <a href="https://google.com">Google</a>
    <div> I am a block element</div>
    <span>I am span and I am inline</span>
    <a href="">yes he is inline</a>

    <!-- Quick Quiz:
    Without using br tag, write a vertically aligned form asking for name, city and pincode of a user.
    Everyone must comment -->

</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Forms - Lets learn it</title>
</head>

<body>
    <h1>Form to apply for Sigma Web Development course - TA </h1>
    <form action="post">
        <div>
            <label for="username">Enter your Username</label>
            <input type="text" id="username" name="username" placeholder="Enter your username" autofocus>
        </div>
        <div>
            <input type="radio" id="male" name="gender" value="male">
            <label for="male">Male</label>
            <input type="radio" id="female" name="gender" value="female">
            <label for="female">Female</label>
        </div>

        <div>
            <input type="checkbox" id="subscribe" name="subscribe" value="yes">
            <label for="subscribe">Subscribe to newsletter</label>
        </div>
        <div>
            <label for="comment">Enter your comment</label>
            <br>
            <textarea id="comment" name="comment" rows="4" cols="50"></textarea>
        </div>

        <div>
            <select name="fruits">
                <option value="apple">Apple</option>
                <option value="banana">Banana</option>
                <option value="cherry">Cherry</option>
          </select>
        </div>
    </form>
</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Images</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <img height="230" src="image.png" alt="Train image">
    <br>
    <table>
        <caption>Employee Details</caption>
        <thead>
            <tr>
                <th>Name</th>
                <th>Designation</th>
                <th>Fav Language</th>
            </tr>
        </thead>
        <tbody>


            <tr>
                <td>Harry</td>
                <td>Programmer</td>
                <td>JavaScript</td>
            </tr>

            <tr>
                <td colspan="2">Sam</td>//colspan means how many column a data will span
                <td rowspan="2">Java</td>
            </tr>
            <tr>
                <td colspan="2">Sam</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="2">Sam</td>
                <td rowspan="2">foot</td>
            </tr>
        </tfoot>
    </table>


    <ul type="square">
        <li>Harry</li>
        <li>Rohan</li>
        <li>Shubham</li>
    </ul>
    <ol type="A">
        <li>Harry</li>
        <li>Rohan</li>
        <li>Shubham</li>
    </ol>

</body>

</html>
git clone https://github.com/AdnanHodzic/displaylink-debian.git
cd displaylink-debian
sudo ./displaylink-debian.sh
* git clone https://github.com/0xbitx/DEDSEC-XICOMAP.git
* cd DEDSEC-XICOMAP
* sudo pip3 install pystyle pycryptodome tabulate tqdm
* sudo python3 dedsec_xicomap.py
* git clone https://github.com/0xbitx/DEDSEC-XICOMAP.git
* cd DEDSEC-XICOMAP
* sudo pip3 install pystyle pycryptodome tabulate tqdm
* sudo python3 dedsec_xicomap.py
db.tweets.updateMany(
    {},
    {
        $unset: {
            "file_name": "",
            "json_data.id_str": "",
            "json_data.display_text_range": "",
            "json_data.source": "",
            "json_data.truncated": "",
            "json_data.favorite_count": "",
            "json_data.in_reply_to_status_id_str": "",
            "json_data.in_reply_to_user_id_str": "",
            "json_data.user.id_str": "",
            "json_data.user.name": "",
            "json_data.user.screen_name": "",
            "json_data.user.url": "",
            "json_data.user.translator_type": "",
            "json_data.user.protected": "",
            "json_data.user.listed_count": "",
            "json_data.user.favourites_count": "",
            "json_data.user.statuses_count": "",
            "json_data.user.utc_offset": "",
            "json_data.user.time_zone": "",
            "json_data.user.geo_enabled": "",
            "json_data.user.geo": "",
            "json_data.user.coordinates": "",
            "json_data.user.is_translator": "",
            "json_data.user.contributors_enabled": "",
            "json_data.user.profile_background_color": "",
            "json_data.user.profile_background_image_url": "",
            "json_data.user.profile_background_image_url_https": "",
            "json_data.user.profile_background_tile": "",
            "json_data.user.profile_link_color": "",
            "json_data.user.profile_sidebar_border_color": "",
            "json_data.user.profile_sidebar_fill_color": "",
            "json_data.user.profile_text_color": "",
            "json_data.user.profile_use_background_image": "",
            "json_data.user.profile_image_url": "",
            "json_data.user.profile_image_url_https": "",
            "json_data.user.profile_banner_url": "",
            "json_data.user.default_profile": "",
            "json_data.user.default_profile_image": "",
            "json_data.user.following": "",
            "json_data.user.follow_request_sent": "",
            "json_data.user.notifications": "",
            "json_data.contributors": "",
            "json_data.is_quote_status": "",
            "json_data.entities.urls": "",
            "json_data.entities.symbols": "",
            "json_data.extended_entities": "",
            "json_data.favorited": "",
            "json_data.possibly_sensitive": "",
            "json_data.filter_level": ""
        }
    }
);
<img src="" alt="">
star

Tue May 28 2024 21:14:04 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

@calazar23

star

Tue May 28 2024 17:14:11 GMT+0000 (Coordinated Universal Time)

@user21

star

Tue May 28 2024 17:12:57 GMT+0000 (Coordinated Universal Time)

@user21

star

Tue May 28 2024 17:11:44 GMT+0000 (Coordinated Universal Time)

@user21

star

Tue May 28 2024 17:10:00 GMT+0000 (Coordinated Universal Time)

@user21

star

Tue May 28 2024 17:08:20 GMT+0000 (Coordinated Universal Time)

@user21

star

Tue May 28 2024 17:06:22 GMT+0000 (Coordinated Universal Time)

@user21

star

Tue May 28 2024 16:58:19 GMT+0000 (Coordinated Universal Time)

@python

star

Tue May 28 2024 16:55:32 GMT+0000 (Coordinated Universal Time)

@python

star

Tue May 28 2024 16:54:50 GMT+0000 (Coordinated Universal Time)

@python

star

Tue May 28 2024 16:53:23 GMT+0000 (Coordinated Universal Time)

@python

star

Tue May 28 2024 16:02:47 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 16:01:48 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 16:01:23 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 16:00:18 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:59:41 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:59:08 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:58:45 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:58:18 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:56:56 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:55:43 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:54:58 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:54:30 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:53:26 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:52:58 GMT+0000 (Coordinated Universal Time)

@adsj

star

Tue May 28 2024 15:37:54 GMT+0000 (Coordinated Universal Time)

@khoa11211

star

Tue May 28 2024 15:24:12 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Tue May 28 2024 15:13:01 GMT+0000 (Coordinated Universal Time)

@Muhammad_Waqar

star

Tue May 28 2024 14:58:38 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Tue May 28 2024 14:28:30 GMT+0000 (Coordinated Universal Time)

@agedofujpn #javascript

star

Tue May 28 2024 13:52:01 GMT+0000 (Coordinated Universal Time)

@StephenThevar

star

Tue May 28 2024 13:50:01 GMT+0000 (Coordinated Universal Time)

@StephenThevar

star

Tue May 28 2024 13:46:28 GMT+0000 (Coordinated Universal Time)

@StephenThevar

star

Tue May 28 2024 07:08:22 GMT+0000 (Coordinated Universal Time)

@manhmd #java

star

Tue May 28 2024 03:22:18 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system-2/

@rahulk

star

Tue May 28 2024 02:49:53 GMT+0000 (Coordinated Universal Time)

@prabhas

star

Tue May 28 2024 02:49:20 GMT+0000 (Coordinated Universal Time)

@prabhas

star

Tue May 28 2024 02:43:50 GMT+0000 (Coordinated Universal Time)

@python

star

Tue May 28 2024 02:27:26 GMT+0000 (Coordinated Universal Time)

@Asadullah69

star

Mon May 27 2024 23:33:58 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Mon May 27 2024 22:16:05 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Mon May 27 2024 21:47:16 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Mon May 27 2024 21:46:23 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Mon May 27 2024 21:26:48 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Mon May 27 2024 21:01:39 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Mon May 27 2024 20:40:14 GMT+0000 (Coordinated Universal Time) https://0xbitx.github.io/0xbit-blog/linux-based-dual-monitor-setup

@samaدghaderi

star

Mon May 27 2024 20:38:44 GMT+0000 (Coordinated Universal Time) https://0xbitx.github.io/0xbit-blog/dedsec-xicomap

@samaدghaderi

star

Mon May 27 2024 20:38:40 GMT+0000 (Coordinated Universal Time) https://0xbitx.github.io/0xbit-blog/dedsec-xicomap

@samaدghaderi

star

Mon May 27 2024 20:35:21 GMT+0000 (Coordinated Universal Time)

@madgakantara

star

Mon May 27 2024 20:32:20 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension