Skip to content

Instantly share code, notes, and snippets.

View jatinsharrma's full-sized avatar

Jatin Sharma jatinsharrma

  • India
View GitHub Profile
@jatinsharrma
jatinsharrma / excelColumnaddress.cpp
Created May 29, 2021 15:49
Excel Column Address problem | CPP | C++
#include <iostream>
#include <math.h>
#define TOTAL 26
/*
Logic
Lets take the example of "A B C"
Let answer = 0
Our String size is 3.
@jatinsharrma
jatinsharrma / squareRoot.cpp
Created May 16, 2021 08:51
Square Root | C++ | Long Division Method
//This only take int data type and input.
//More inprovment can be done, example in helper we can use binary search.
#include <iostream>
#include <vector>
std::vector<int> getPairs(int num)
{
std::vector<int> pairs;
while(num){
@jatinsharrma
jatinsharrma / temp_conversion.cpp
Created March 18, 2021 07:10
c ++ | Temperature conversion | Celsius, Kelvin, Fahrenheit
#include <iostream>
using namespace std;
//---------------Function Declaration----------------
void error(std::string); // returns error
bool valid_temp(double); // check for valid temprature in Kelvin | Below 0K is invalid
double ctok(double); // convert Celsius to Kelvin
double ktoc(double); // convert Kelvin to Celsius
double ftoc(double); // convert Fahrenheit to Celsius
double ctof(double); // convert Celsius to Fahrenhiet
@jatinsharrma
jatinsharrma / attribute_parser.cpp
Created March 17, 2021 14:28
c++ | Attribute Parser | Hackerrank
// problem link : https://www.hackerrank.com/challenges/attribute-parser/problem
#include <iostream>
#include <vector>
const int start = 1;
const int end = 0;
//------------User defined Data types ----------------
@jatinsharrma
jatinsharrma / calculator_v3.cpp
Last active March 5, 2021 11:49
Calculator | C++ | Programming -- Principles and Practice Using C++ by Bjarne Stroustrup
/*
The grammar for input is:
Calculation :
Statement
Print
Quit
Calculation Statement
Statement:
Declaration
@jatinsharrma
jatinsharrma / calculator_v2.cpp
Created March 3, 2021 09:33
Calculator | C++ | Programming Principles and Practice Using C++ : Bjarne Stroustrup
// Programming Principles and Practice Using C++ : Bjarne Stroustrup
// Chapter 6
#include <iostream>
#include <vector>
using namespace std;
// class Token_stream; // member functionss : putback(), get()
// class Token; // Token class, member varaibles : kind, value;
double expression(); // Exp = Exp or Exp + Term or Exp - term
@jatinsharrma
jatinsharrma / Extract.sh
Created July 4, 2020 15:06
Extract Multiple ZIP / RAR files from one directory to another. Shell Script
#!/bin/bash
#Script to extract Multiple RAR files and place each RAR file's content in its own directory
for z in *.rar
do
# removing all white space. Generating Directory name
c="$(echo -e "${z}" | tr -d '[:space:]')"
# Creating directory. Replace <Directory Address> with your own Directory Address.
mkdir /<Directory Address>/$c;
@jatinsharrma
jatinsharrma / MathemacticalEvaluator.kt
Last active July 1, 2020 17:41
Mathematical Expression Evaluator : For Calculator
// Python code for this problem : https://gist.github.com/jatinsharrma/e64bfbe225d9d97d770873d4700e5765
// This program is based on Operator Precedence Parser concept.
var lastNumeric : Boolean = false
var lastDot : Boolean = false
var stack = ArrayList<String>()
var parCount : Int = 0
var parFlag : Boolean = false
var wrongFlag : Boolean = false
@jatinsharrma
jatinsharrma / MathemacticalEvaluator.py
Last active July 1, 2020 17:28
Mathematical Expression Evaluator : For Calculator Application
#--------------------------------------------------------------------
#--------------Mathematical Expresion Evaluater----------------------
#--------------------------------------------------------------------
'''Logic:
this program makes use of the operator precedence parser concept.
(An operator precedence parser is a Compiler Design Concept)
There are checkpoint you can uncomment those to see how code is running
@jatinsharrma
jatinsharrma / threeNumberSum.py
Last active May 15, 2020 18:40
Find all triplets whose sum is equal to given number.
# ////////////////////////////////////////////////
# --------------Three Number Sum-----------------
# ///////////////////////////////////////////////
# time complexity O(n^2)
# space complexity O(n)
def tripletSum(arr, v):