A data structure that uses a hash function to map identifying values, known as keys, to their associated values

learn more… | top users | synonyms (1)

1
vote
0answers
21 views

A homemade variadic map

A bit of background: some time ago I wrote a piece of code that can be used for memoization with functions taking one parameter. Now I want to extend this to deal with functions with arbitrary number ...
2
votes
3answers
72 views

LeetCode 49: Group Anagrams

I'm exceeding the time limit for a 10,000 word test case provided on LeetCode: Given an array of strings, group anagrams together. For example, given: ...
0
votes
1answer
61 views

Hash Table or map implementation

I'd like to get feedback on whether my hash table is correct or not. Also, any ideas on performance? ...
1
vote
1answer
28 views

Parsing string into hash-map with 2D coordinates as keys

I had never programmed in a functional programming language before. I think that this function has large nesting. Is there way to rewrite it better? I am most worried about the use of "flatten". Is ...
-2
votes
1answer
46 views

Simple example of a hash table using square as key

I'm studying hash tables, and wrote the following to serve as a simple example. Does this properly demonstrate the basic concept of a hash table? The values are ...
1
vote
3answers
55 views

HashMap keys to sorted List

The idea is to obtain the keys as a list ordered by the natural ordering of the keys but first of them all the ones that have priority, stated by the method hasPriority(). The custom comparator code ...
2
votes
1answer
60 views

determine if two strings with unrecognized letters are from the same text

Given two Strings S and T of N=>1 and M=>1 characters, respectively, with unrecognized letters (an unrecognized letter is marked by "?", for brevity, every group of K consecutive "?" characters is ...
0
votes
0answers
16 views

Mapping fields and data from PDF to SOAP with hashMaps

I have a PDF form which I scrape the data from each field and value and store it in a hashmap. I need to map this data to different field names before inserting it into a SOAP message. The PDF has ...
5
votes
1answer
195 views

HackerEarth - SimpleFunction

Problem statement Let us first describe a SimpleFunction: ...
4
votes
1answer
73 views

Using two maps and making a new map by applying all the transformations

I have two JSON and each JSON I am loading in a Map. First JSON { "abc": "2", "plmtq": "hello+world", "lndp": "def+ooo", "yyt": "opi" } I am ...
1
vote
1answer
54 views

Finding numbers divisible by primes in a given range

The problem statement (Codeforces# 385C) is this: We are given a sequence of \$n\$ numbers, i.e. \$x_i\$ and \$m\$ queries to find how many of these are divisble by primes between two given numbers ...
2
votes
3answers
140 views

Android recyclerview filter

I want to optimize the below code, I have asked a similar question here. I know this approach is better than my last code but I feel there are ways to optimize this too.This code is used in almost ...
5
votes
2answers
70 views

Increment all values in a Map by 1

What's the neatest way to increment all values in a HashMap by 1? The map is <String, Integer>, but the key doesn't matter ...
0
votes
3answers
141 views

Map class made easy for beginners to understand

I want to explain to beginners what a Map is in Java, with the assumption that beginners do not understand what a hashcode is. As I developed games (Tarot, Belote, ...
0
votes
1answer
34 views

Quadratic probing and hashing - search for words in text files

I created a program for a college class. After I got it working, I wanted to improve it. As a beginner, it is probably a mess. Description It uses a HashFunction ...
2
votes
1answer
94 views

Java 8 streams - restructure entity classes for UI Grid

I have the following domain model: ...
1
vote
1answer
37 views

Binary Option Pricing using Card Game

I shuffle a deck of cards(with an equal number of red and black cards) and start dealing them face up. After any card you can say “stop”, at which point I pay you $1 for every red card dealt and ...
0
votes
0answers
28 views

Optimizing List creation

Using IBM JT400 toolbox, I'm reading records from a DB2 keyed table (it's like reading a ResultSet with ResultSet.next()). As what I'm building is an higher level ...
3
votes
1answer
106 views

Data structure (Map-like implementation) in C++

I wrote this code to implement a data structure in C++. It works perfectly, however, I am looking to improve its efficiency. Also, I'm just getting started in C++ so using code to explain your ...
0
votes
0answers
49 views

Data structure that supports binary search and has near constant insertion and deletion times

I'm trying to create a data structure that has the following properties: must be able to perform a binary search based on a on-the-fly computed value ideally must have an \$O(1)\$ insert and delete ...
2
votes
1answer
65 views

Speed up code based on map with vectors as values

Following is the piece of code which represents the bottleneck of my application: ...
2
votes
1answer
51 views

Building and querying an immutable phone book

I wanted to get your opinion on this immutable implementation of a Phone Book using recursion to process a stream. I am especially interested in ways to speed up the code execution. Here is an ...
5
votes
1answer
72 views

Fixed capacity unordered_map

I have a need for a container that behaves like an unordered_map, but has a fixed capacity, and an eviction policy where the least recently inserted key-value pair ...
7
votes
2answers
120 views

Hash map implementation

I'm a student in college, and while I have coded a lot, I still feel like I've only scraped the surface. I have learned a lot of things over the years, but very few of my professors ever did code ...
4
votes
1answer
48 views

Python Dictionary Manipulation

I just finished working on a coding challenge for learning Python 2.7. Essentially, I'm a function that if it is fed a string such as: ...
1
vote
2answers
123 views

Alternative to using Object and casting in a map

I have the following class which represents a set of properties. ...
2
votes
0answers
85 views

HashMap with binary search tree for chaining

My friend was asked to implement a hashtable with a binary search tree. I tried practicing it myself, and it turned out to be very verbose. I need suggestions to clean this up! ...
3
votes
4answers
75 views

Optimizing Java SHA-512 String-to-Hash Generator

In an attempt to learn Java and SHA-2 I created a very simple String-to-SHA512 generator. Here is the code: ...
2
votes
3answers
430 views

Simple Chaining Implementation of HashMap

I'm practicing writing my own simple version of a Java HashMap. I don't have much experience with generics in Java. ...
2
votes
1answer
64 views

Bare bones implementation of Java HashMap

I've done a minimal implementation of a HashMap. Invite comments. ...
4
votes
1answer
111 views

Prints Books from a HashMap that are complete or incomplete

This code is meant to display book titles that are incomplete. I have a HashMap with the book title and a number that represents the amount of the book that has ...
4
votes
1answer
339 views

Using a LinkedList type of adjacency list to create the word game: WordLadder

The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter. Start: gain End: fire Output: ...
2
votes
2answers
449 views

Print max occurring character in a String

This prints the character that occurs the most in a given string. Input: String of word(s) Output: Max occurring character ...
3
votes
1answer
63 views

class Taboo<T> — sort passed in List<T> according to 'rules'

I know as a matter of fact that there are many areas upon which my code could be improved. I was wondering if anyone can provide me with suggestions on how Taboo ...
0
votes
3answers
433 views

Detecting if two given strings are isomorphic using Java data structures

So I have written the following code and it works for various same length isomorphic strings I have tried. However I am not sure what are some time complexity improvements and coding tweaks that could ...
0
votes
0answers
22 views

Converting from a madlib program using hashmaps to using 3 different arrays to hold the noun, verb, and adjectives

Using erb and Sinatra, I need to make an array of each variable that can be added in, [noun], [verb] and [adjective], allowing me to return the number of each there are and create the appropriate ...
5
votes
1answer
736 views

Replacing multiple substrings in a string

Here are 2 functions defined that do the exactly same thing: take input a template (in which one wants to replace some substrings) and array of strings values (key value pair to replace, such as [...
4
votes
2answers
100 views

Is this the right way to implement a simple hash table in C++?

Does this look like a proper implementation of a hash table in C++? Any errors anyone can find? Thanks in advance (: ...
1
vote
1answer
115 views

A basic pure Python hash map using a tree

I would like feedback on my first attempt to understand how hash tables work. I've read some on how hash tables use modulo operations to find the location of a key. Can you help me understand, ...
4
votes
1answer
127 views

Evicting an entry from a size-limited HashMap<T, Integer>

I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one. I already have this working ...
3
votes
1answer
71 views

“Space and Time Efficient” way of finding all anagram groups

I have written a program to find all anagram groups in a text file. I used first 26 Prime numbers as a mapper for 26 characters for finding anagram groups (Since character_set of all anagrams of a ...
8
votes
2answers
835 views

Program to index a book

Indexing a book. Write a program that reads in a text file from standard input and compiles an alphabetical index of which words appear on which lines, as in the following input. Ignore case and ...
3
votes
2answers
400 views

Custom C++ iterator

So I have written a custom iterator for std::map that allows access to just the "values" of the map and I was wondering if it is the "correct" way to implement <...
5
votes
2answers
165 views

Registering and looking up aliases

I've taken a coding challenge as part of a job interview and the recruiting process. Sadly I didn't get through it and couldn't secure the job. I am wondering if anyone can help me out here and show ...
0
votes
3answers
111 views

Database of students

At first, I had Database to contain std::list<Student> students, but because there are over 2000 students, searching by ...
3
votes
1answer
90 views

Bidirectional map

For fun and to learn a bit, I decided to implement a bidirectional map in Ruby, relying on Ruby core libraries where possible. Its behavior is intended to be that of a Ruby Hash, but one in which '...
2
votes
1answer
312 views

Minimal Map implementation with weak values

What follows is an implementation of the java.util.Map interface with weak values. This means that entries should be removed from the map when their values become ...
8
votes
2answers
2k views

Simple linked hash map in JS (Node/browser)

I needed a simple data structure to cache the most recent few directory contents for this project I was working on. I thought a linked hash map would be the right approach since we will cache only one ...
10
votes
2answers
2k views

Implementation of fixed size hash map

I'm trying to brush up on my algorithms and data structures and wrote a fixed sized hash map assuming both key and value will be only integers. This is a significant simplification of the real case ...
4
votes
2answers
1k views

Performance of hashmap-based session object

Unfortunately, I can't use the Tomcat session for storing the key/value pairs for each user (restricted because it's an IVR domain-based project). But I need the same functionality like a ...