Skip to content

Instantly share code, notes, and snippets.

View gauravbhasin87's full-sized avatar
🏠
Working from home

gauravbhasin87

🏠
Working from home
View GitHub Profile
/* There are NN strings. Each string's length is no more than 2020 characters. There are also QQ queries. For each query, you are given a string, and you need to find out how many times this string occurred previously.
Input Format
The first line contains NN, the number of strings.
The next NN lines each contain a string.
The N+2N+2nd line contains QQ, the number of queries.
The following QQ lines each contain a query string.
Constraints
@gauravbhasin87
gauravbhasin87 / DynamicArray.java
Created March 13, 2016 01:44
Dynamic Array - Implementation of Hash Table
/*
There are NN sequences. All of them are initially empty, and you are given a variable lastans=0lastans=0. You are given QQ queries of two different types:
"11 xx yy" - Insert yy at the end of the ((x⊕lastansx⊕lastans) mod NN)th sequence.
"22 xx yy" - Print the value of the (yy mod sizesize)th element of the ((x⊕lastansx⊕lastans) mod NN)th sequence. Here, sizesize denotes the size of the related sequence. Then, assign this integer to lastanslastans.
Note: You may assume that, for the second type of query, the related sequence will not be an empty sequence. Sequences and the elements of each sequence are indexed by zero-based numbering.
The ⊕⊕ symbol denotes the xor operation. You can get more information about it from Wikipedia. It is defined as ^^ in most of the modern programming languages.
Input Format