Skip to content

Instantly share code, notes, and snippets.

View haikentcode's full-sized avatar

hitesh kumar regar haikentcode

View GitHub Profile
@haikentcode
haikentcode / removeKfromLinkList.py
Created December 12, 2017 18:23
Delete all occurrences of a given key in a linked list
@haikentcode
haikentcode / lcm of array .py
Last active November 4, 2016 21:25
find lcm of array ( list ) in python
def gcd(a,b):
# if a==0:
# return b
# return gcd(b%a,a)
return agcd(a,b)
def agcdUtil(a,b,p):
if a==0:
@haikentcode
haikentcode / binaryIndexTree.py
Created August 18, 2016 08:16
Binary Indexed Tree or Fenwick Tree
class Bit:
def __init__(self,a):
self.a = a
self.n = len(a)
self.bit = [0]*(self.n+1)
for i,x in enumerate(a):
if i == 0 : continue
self.update(i,x)
def update(self,x,val):
@haikentcode
haikentcode / tri.cpp
Created August 7, 2016 20:46
Trie |(Insert and Search )
#‎include‬<iostream>
#include<cstring>
using namespace std;
‪#‎define‬ ALPHA_SIZE (26)
#define GET_INDEX(c) ((int)c-(int)'a')
class Dic
{
struct node
{
int value;
@haikentcode
haikentcode / WORDAMENT.cpp
Created August 7, 2016 20:40
WORDAMENT( WAP to search a word in N*N grid with one char in each cell.)
/*
WORDAMENT
program
{
WAP to search a word in N*N grid with one char in
each cell.
move direction allow::( vertically,horizontal,diagonal)
direction are
@haikentcode
haikentcode / diff.cpp
Created August 7, 2016 20:33
diffrence between char s[]="hello"; or char *s ="hello"
/*
HIOS@Study material
Topic :: Different between
1: char s[]=" hios technology ";
2: char *s=" hios technology " ;
*/
@haikentcode
haikentcode / microsoft internship problem.cpp
Created August 7, 2016 20:31
microsoft internship problem
/*
1) Given a string, you have to check if it is a valid number or not.(The number can be signed, floating point/integer).
If it is a number return true else return false.
The constraints were :-
i) No decision statements allowed (No if-else,no switch-case).
ii) No ternary conditional operators allowed (? : not allowed).
iii) No looping statements allowed (No for/while/do-while).
@haikentcode
haikentcode / binary representation of a number is palindrome.cpp
Created August 7, 2016 20:30
Check if binary representation of a number is palindrome
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
bool check(int n)
{
@haikentcode
haikentcode / Object into binary.cpp
Created August 7, 2016 20:28
Convert c/c++ Object into binary form ( int ,float ,char ..etc to binary )
/*
After 2hrs effort I have completed this :)
HIOS@PRODUCT
CODER# @haikent hitesh
-> conert any c /c++ object int binary form (int,float,char,struct data.....)
<for gudan>
*/
#include<iostream>
using namespace std;
@haikentcode
haikentcode / Primality Test
Created August 7, 2016 20:26
Primality Test
import math
import sys
import random
def log2(n):
return math.log(n)/math.log(2)
def power(x,y,p):
'(x^y)%p'
res=1