Skip to content

Instantly share code, notes, and snippets.

@iamgauravbisht
iamgauravbisht / ImageTools.js
Created March 25, 2024 06:13 — forked from SagiMedina/ImageTools.js
Resize and crop images in the Browser with orientation fix using exif
import EXIF from 'exif-js';
const hasBlobConstructor = typeof (Blob) !== 'undefined' && (function checkBlobConstructor() {
try {
return Boolean(new Blob());
} catch (error) {
return false;
}
}());
@iamgauravbisht
iamgauravbisht / Syntax.py
Created February 28, 2024 15:45
To Revise Syntax of Python Fast
# print("hello to world from gaurav");
# input will always be a string you have to typeCast to turn them into your desired data type
# x=int(input("Enter a number \t"));
# print (x);
# print(type(x));
# if else
# if x>18:
# print("you are an adult")
@iamgauravbisht
iamgauravbisht / Context.tsx
Last active January 23, 2024 17:22
Creating Store using Context API
import React, { createContext, useReducer } from "react";
type IState = {
loginEmail: string;
loginPassword: string;
};
const initialState: IState = {
loginEmail: "",
loginPassword: "",
};
@iamgauravbisht
iamgauravbisht / PowerOFX.java
Created December 31, 2023 12:34
X to the Power n using Recursion
package Recursion;
public class PowerOFX {
// Iterate
public static int itr(int x , int power) {
int result = 1;
for(int i = 1 ; i <= power ; i++ ){
result = result * x;
}
return result;
package Recursion;
import java.util.Scanner;
public class Recursion {
//Factorial
public static int fact( int n ){
System.out.println("factorial of " + n);
if( n <= 1 ) return 1; //Base Condition
return n * fact(n-1);
}
@iamgauravbisht
iamgauravbisht / Converter.java
Created December 29, 2023 12:41
converter for decimal to binary and binary to decimal
package Bitwise;
import java.util.Scanner;
class Converter{
public String toBinary(int n) {
String result = "";
while(n != 0){
int lastbit = n & 1;
result = lastbit + result;
n = n >> 1;
@iamgauravbisht
iamgauravbisht / DecimalToBinary.java
Created December 28, 2023 23:08
Decimal To Binary
package BinaryAndDecimal;
import java.util.Scanner;
// Decimal to Binary Conversion
public class DecimalToBinary {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.print("Enter a number : ");
int decimal = s.nextInt();
String result ="";
@iamgauravbisht
iamgauravbisht / Quad.java
Created December 24, 2023 20:59
Quadratic ->O(n^2) Space Time Complexity
package spaceTimeComplexity;
public class Quad {
public static void main(String[] args) {
int[] arr= new int[]{1,2,3,4,5,6,7,8,9,0,4,10};
int target=10;
// Find the pair of Values in Array whose sum is equal to target
for(int i=0; i<arr.length;i++){ // Time C. -> O(n)
for (int j= i+1; j<arr.length;j++){ // Time C. ->O(n) times O(n) -> O(n^2)
@iamgauravbisht
iamgauravbisht / Logarithmic.java
Created December 24, 2023 20:43
Logarithmic Space Time Complexity
package spaceTimeComplexity;
public class Logarithmic {
public static void main(String[] args) {
//Binary Search
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int target = 6;
int left = 0;
@iamgauravbisht
iamgauravbisht / Linear.java
Created December 24, 2023 19:41
Linear Space and Time Complexity
package spaceTimeComplexity;
import java.util.Arrays;
public class Linear {
public static void main(String[] args) {
int[] arr =new int[]{1,2,3,4,5,6};
//in our Constant space complexity the notation was O(1)
arr[0]=arr[0]+10; //System Complexity -> O(1)
System.out.println("arr[0] : " + arr[0]); //Time Complexity -> O(1) System Complexity -> O(1)
// Print elements of the array