Questions tagged [hash-map]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
127 views

Extracting data from dict and processing it

Consider the following ...
1
vote
1answer
38 views

How to exclude elements from an array based on a Map while maintaining O(n)?

I am trying to exclude some elements from array items that include properties from array excludes. I wrote this code which works ...
3
votes
2answers
65 views

Parsing a std::string to a dictionary (std::map)

As always - the context ! Preliminaries Recently I needed a way to transport data from one environment to another. Though the proper way (probably) to do this would be to use databases (which I don't ...
1
vote
2answers
89 views

Find most occurring word in a sentence

Here is my C code for finding the most occurring word in a sentence: ...
0
votes
1answer
54 views

Use an exception to check if item in dictionary [closed]

I am using a KeyNotFoundException to check if an item exists in a Dictionary, creating it when the exception is thrown: ...
1
vote
1answer
38 views

React - Component rendering weather data

Background: Hello, I'm a student (since 2 months) and I've created a small MVP of a weather application. So now I'm refactoring my code because it looks hideous and it is hard to work with. The ...
5
votes
1answer
90 views

Open addressing linear probing hash map

Here is my wheel. strmap - C string hash map. Main goal - create usable and simple alternative to hcreate_r, ...
3
votes
1answer
56 views

LetterDict, a dictionary whose keys must be lowercase letters [a-z]

Looking for any suggestions - alternative design, improvements to readability, improvements to the comments, etc. I implemented this letter dictionary to see if it would faster than a regular ...
2
votes
1answer
41 views

word frequency distribution

wordList is an array of non-empty strings ("words"). The following code I have written with the purpose of obtaining a Map, containing the unique words ...
3
votes
1answer
97 views

ZigZag Conversion Coding Challenge

This is my solution for ZigZag Conversion, a coding challenge from LeetCode. The challenge: Write a program that takes two parameters, a string and a number of rows, that interprets the string as if ...
4
votes
2answers
143 views

Prioritise injured cats for treatment (dictionary/map search optimization Python and C++)

I am once again attempting another CP problem, and I have ONCE AGAIN run into an optimization issue because of the time limit of one second: https://open.kattis.com/problems/doctorkattis It is common ...
1
vote
0answers
42 views

Counting Cram game positions in C

This code counts the number of possible positions in the game of Cram on a mxn board. EDIT 1: In the original question I mistakenly mentioned that this number is ...
3
votes
1answer
108 views

Better way of comparing two lists of dictionaries and display unique changes

Can I get a review of my code which compares 2 dictionaries and display unique changes. ...
2
votes
1answer
152 views

Robin Hood hashing

This is an implementation of a "string to int" hash table with Robin Hood hashing. I have tested it as thoroughly as I could. It appears to have no bugs/leaks. I would appreciate any ...
1
vote
1answer
427 views

Finding nodes with 0 or 1 parents - DFS or BFS

I completed the following question but it seems a lot of space complexity. Do you think is there a way to complete it with graph search or so? Thanks for the comments. Suppose we have some input data ...
6
votes
1answer
146 views

Python function to print a two-column table from a dictionary

I'm currently learning Python for a masters and am trying to improve the best I can, as I'll need to know how to code in my future career. I currently have a function that builds a table from a ...
6
votes
1answer
1k views

friend locator app

I was rejected after a tech screening for the following code. I mainly struggled to make the code 'production ready'. I was running out of time so I did not create a class for testing. How could I ...
9
votes
2answers
2k views

Efficient renaming of dict keys from another dict's values - Python

I have a dictionary in Python (uglyDict) that has some really un-cool key names. I would like to rename them based on values from another dictionary (...
1
vote
1answer
57 views

Hashing Table in Python

I just want your opinion about that code! :) ...
2
votes
0answers
74 views

Compute damages and savings for motor insurance claims

I am working on some claims data, where I have features such as The descriptions of the columns are: (A) the year of claim, (B) who's the insuring company (C) whether the vehicle is driven, (D) ...
9
votes
3answers
1k views

The cleanest way to print the max value and its key from a dictionary

I'm getting the highest value and its respective from a dictionary and printing it out for the user. Even though it's working, I'm wondering if I'm doing it in the cleanest way. Here it is: ...
2
votes
1answer
62 views

Sports DataSheet

This program asks the user for a players name, # of goals, saves, games played, etc. This information is ten organized on a .txt file along with the time the information was logged. users can also ...
1
vote
1answer
42 views

I have a query like this that seems complicated and I want to do it by using Java Stream Api

I have method that fetches sorted and filtered data from Mysql Database, Firstly I had done It by using Java. Now I did it by Mysql but I don't like the way the code looks I have entity that named ...
2
votes
1answer
50 views

Implementing hash table in Python using Tuples

I am trying to implement a basic hash table using a list of tuples. The code produce the desired output. Please help me improve my code as I feel there are a lot of while loops. ...
5
votes
2answers
810 views

Hashmap implementation in C++

I have been asked to implement a HASHMAP in C++ in a job interview (home assignment). I'm a bit unsure about exception safety, but this is what I came up with: Block.h ...
0
votes
0answers
56 views

Quadratic Probing Hash Map - questions about implementation and testing

Quadratic Probing Hash Map Looking to improve my quadratic probing hash map. Here are some design considerations and questions. Implementation is made such that the hashing function, probing function ...
2
votes
0answers
399 views

3Sum - leetcode

Question: Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set ...
0
votes
0answers
58 views

Is this a good way to construct the class for a C++ template partial specialisation of a member function?

I am teaching myself c++ by doing a series of exercises. I liked the idea of working out how hash tables could be done using just the language and no std calls. I discovered that you cant do "...
6
votes
2answers
2k views

Income tax rate calculator in c++

I have been trying to learn c++ for the sake of being comfortable with a second language. I found a project that seemed relatively easy, although it may not be implemented perfectly, it was a simple ...
2
votes
1answer
58 views

Hash Table implementation in C using linear probing for collisions

I've written a simple Hash Table implementation in C, in order to use it in an IRC bot, so mostly storing nicknames, channel names, etc (small strings). I'm using linear probind to resolve collision. ...
3
votes
2answers
79 views

Create a dictionary from a list of key and multi list of values in Python

I have a list of key: list_date = ["MON", "TUE", "WED", "THU","FRI"] I have many lists of values that created by ...
3
votes
1answer
71 views

Aggregating hourly location data into daily sublocation data for many columns

I start with an hourly table that has around 40 of items (example: bread, barley, bagels, beef, chicken). The purpose of my code is to aggregate this hourly table's numbers to daily numbers but broken ...
5
votes
2answers
733 views

Hash table implemented in C with open addressing

While posting this, I noticed there are quite a few similar C hash table implementations here already. So I figured one more wouldn't hurt. :-) In any case, I'm writing a teaching article on "how ...
2
votes
1answer
43 views

Linked list that support modifications during iteration

Update: Fixed last item is not removed during iteration Fixed clear() during iteration does nothing Fixed addition of removed item is ignored The lasted code can ...
4
votes
1answer
115 views

lazy_map implementation in C++ | Similar to unordered_map but O(1) copyable

I implemented lazy_map - https://github.com/tinytrashbin/lazy_map. Can someone help with reviews ? lazy_map is an implementation of unordered_map that has O(1) cost of copying irrespective of the ...
13
votes
3answers
2k views

Count word frequencies, and print them most-frequent first

I'm writing a comparison of a simple word-counting program in various languages. The task is to count the frequencies of unique, space-separated words in the input, and output the results most ...
1
vote
0answers
37 views

Global Dictionary Class

For a Django-Server I use several custom Error-Codes, error-titles and descriptions, possibly other fields might follow. I'm using right now a basic global dictionary. ...
0
votes
1answer
29 views

Calculating ordered differences between elements in vector

Input I start with a vector of integers or floats, e.g.: [10, 100, 20, 5, 50] Output I want to return a list of differences or "deltas" between elements ...
2
votes
0answers
65 views

Hash table library implementation

I wrote my own implementation of generic hash table. I’m using linked list to resolve collision problem. I want to share my code with you and get your opinion about it, and if there are any advice or ...
3
votes
1answer
251 views

Hashtable with separate chaining and dynamic resizing

An attempt at a clean implementation of this important data structure in C. It's hard to make such structures generic in C without losing performance, so this specialises on ...
4
votes
1answer
94 views

Data set with many variables in Python, many indented dictionaries?

I am working with a data set that has many variables. Currently I am storing the data in many indented dictionaries in the following way: ...
1
vote
2answers
84 views

Finding duplicates in multiple lists for configuration validation

I have created helper class for configuration validation, the main purpose is to find any human "errors" in the configuration for the app. the case is that any type of "message" ...
2
votes
1answer
185 views

Generic hashmap with dynamic resizing and collision handling

This is a (more or less) continuation of a previous post I made: Generic implementation of a hashtable with double-linked list. I got lots of valuable feedback, so I decided to rewrite the entire ...
1
vote
2answers
2k views

How to make Map<String, Object> expendible(?) safely in java

I am building some statistic counter in Java. Each metric could have flexible depth so the implementation should able to explore the depth when value insert or update. So I implement like below (with ...
3
votes
2answers
2k views

Simple Hashmap in C

I've been working on a simple hashmap in C. Here is hashmap.h: ...
4
votes
3answers
252 views

Generic implementation of a hashtable with double-linked list

I implemented a hashtable that handles collisions by chaining entries using a double linked list. The idea is that it can store/lookup any kind of generic data structure, while maintaining an API that ...
0
votes
1answer
162 views

Nested dictionary creation with setdefault

Is there a better way of creating a nested dictionary than what I'm doing below? The result for the setdefault is because I don't know whether that particular key ...
3
votes
0answers
72 views

Modeling data from Excel sheets to parse to Excel sheet

Background: I have close to 50 excel files - I cannot change the data source - and I steadily get more. My task is to make sense of all that data and, lo an behold, save that as another excel file (I ...
2
votes
1answer
69 views

Print the App Name Using Latest Version

I am trying to solve a problem, where we are given an app name, service name, and version number of an api. We need to print the name of app, which is using the latest version for most of the service. ...
2
votes
0answers
53 views

Hashtable Visualizer in TypeScript

Implementation is based on the MVC design pattern, with callbacks to allow model and view to communicate with controller. Concerns: It's not ideal to have async code inside the model, i.e the model ...

1
2 3 4 5
17