GithubHelp home page GithubHelp logo

mathprogrammer / hacker-earth Goto Github PK

View Code? Open in Web Editor NEW
46.0 7.0 42.0 409 KB

This is my HackerEarth Handle

Home Page: https://www.hackerearth.com/@ghoshsai5000

C 8.59% C++ 90.74% Java 0.67%
hackerearth-solutions hackerearth competitive-programming algorithm-challenges mathematics

hacker-earth's Introduction

Hacker-Earth

hacker-earth's People

Contributors

mathprogrammer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hacker-earth's Issues

Memory Limit Exceeded using same concept

Hi, I used the same concept as you described for this question. I just used map implementation of trie and I ain't able to pass more than 1 test case. Can you please help me out ?? My code :

#include<bits/stdc++.h>
using namespace std;

struct trie{
	// bool end=false;
	int num=0;
	map<int,trie* > lk;

};
trie* root=nullptr;

trie* get(){
	trie* temp =new trie;
	temp->num=0;
	return temp;
}

void add(int n){
	if(root==nullptr)root=get();
	trie* node=root;
	for(int i=32;i>=0;i--){
		int val=(n & 1LL<<i)?1:0;
		if(node->lk.find(val)==node->lk.end())
			node->lk[val]=get();
		node=node->lk[val];
	}
	node->num=n;
}

int search(int n){
	if(root==nullptr || n==0)return 0;
	trie* node=root;
	for(int i=32;i>=0;i--){
		int val=(n & 1LL<<i)?1:0;
		if(node->lk.find(val)==node->lk.end())
			node=node->lk[1-val];
		else node=node->lk[val];
	}
	return node->num;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);
	int i,j,k,n,m=0;
	cin>>n;
	while(n--){
		cin>>j;
		if(j==3)cout<<(m^search(m))<<"\n";
		else cin>>k;

		if(j==1)add(k^m);
		else if(j==2)m^=k;
	}

	return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.