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
1 vote
1 answer
1k views

HashTable implementation in Python 3

I have implemented a hash table. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
Brijesh Kalkani's user avatar
5 votes
2 answers
2k views

Fantasy Game Inventory - Automate the Boring Stuff with Python

Below is my code for the Fantasy Game Inventory problem from Chapter 5 of Automate the Boring Stuff with Python. Is there anything I can do to make it cleaner or more efficient? The code starts out ...
cyberprogrammer's user avatar
3 votes
1 answer
150 views

identifying pairwise groups from dictionary

I have a dictionary that looks like this ...
Pythonprotein's user avatar
5 votes
3 answers
1k views

Comparison of values in dictionary

I have the following dictionary: ...
Javier Lopez Tomas's user avatar
3 votes
1 answer
133 views

How do I efficiently create a dataframe from a list of dictionaries?

I used this API to download some data. The code is supposed to create a dataframe table using specific fields of an object, and it seems to work, but running slow. I think it would run faster if I ...
help-ukraine-now's user avatar
-1 votes
1 answer
123 views

Dictionary comprehension with nested for loop and conditional if [closed]

Let's suppose I have two lists: list_b = ['cat.2','dog.6','bear.10','zebra.13'] list_a = ['cat','dog','bear','zebra'] I would like to create a dictionary with ...
Andrew Hamel's user avatar
4 votes
2 answers
103 views

Mini-git class performance issue

I want to build Git class where i can store integers. FilesSet is where I store current state of integers. Commits' key is ...
Jubick's user avatar
  • 153
3 votes
1 answer
350 views

LeetCode: Time Based Key-Value Store C#

https://leetcode.com/problems/time-based-key-value-store/ Create a timebased key-value store class TimeMap, that supports two operations. ...
Gilad's user avatar
  • 5,321
3 votes
2 answers
101 views

Large matrix with lots of repetitive fields (C++)

I wrote a timetabling program and I have been using a matrix to check for clashes between courses. Index (i, j) in the matrix ...
cj1996's user avatar
  • 33
4 votes
1 answer
96 views

Immutable Keyed Set

Description An immutable keyed set is a readonly collection of elements without duplicates or null values having each of the elements linked to exactly one key. Example This simple example ...
dfhwze's user avatar
  • 13.9k
2 votes
2 answers
15k views

Python, Iterate through a list sending batches of 100 records at a time to an API, then appending results to another list

I have a list of 9000 dictionaries and I am sending them to an API in batches of 100 (limit of the API). The API returns the list of 100 dictionaries just expanded with more key/value pairs. So both ...
DBA108642's user avatar
  • 123
1 vote
0 answers
42 views

Checking for a values existence: slice iteration vs map lookups in Go [closed]

Assuming I have the following slice: mySlice := []string{"one", "two", "three"} and I want to know whether or not it contains a given string, say ...
Robbie Milejczak's user avatar
4 votes
3 answers
3k views

Bidirectional Map in C#

Inspired by this question and its answers, I've made my own version. ...
user avatar
9 votes
5 answers
2k views

Bidirectional Dictionary

The management of bidirectional mappings is a reoccuring topic. I took the time to write an (hopefully) efficient implementation. ...
Benj's user avatar
  • 389
5 votes
1 answer
126 views

Automating a set a of weekly reports, including graphs and delivery of reports

I have been writing code to automate some weekly reports. I had help over on Stack Overflow. I have code that works for the most part, however there are a few things that I just can't seem to fix. In ...
Moo10000's user avatar
9 votes
1 answer
806 views

Convert to dictionary

Earlier I did post with full code about Prepare and export data to MS Word file. The user t3chb0t recommended me to separate some part of full code to this post. Context The task of code for review ...
Viewed's user avatar
  • 294
4 votes
2 answers
807 views

Reverse Dictionary: Group from child array elements and get its minimum key

Objective I have following array and would like to group by each child and get its smallest Id:- ...
Zephyr's user avatar
  • 225
1 vote
0 answers
331 views

Custom HashMap implementation in Java with Linear Probing

I have taken a stab at implementing a HashMap in Java. To deal with collisions I implemented sort of a LinkedList using a dataNode. I am not very confident of my implementation hence looking for some ...
Rahul Wadhwani's user avatar
6 votes
3 answers
2k views

LeetCode: Group Anagrams C#

LeetCode: Group Anagrams C# Given an array of strings, group anagrams together. ...
Gilad's user avatar
  • 5,321
2 votes
1 answer
150 views

Comparing web-scraped data from several sports betting APIs

I have written a python script that requests information from several Sports Betting API's, processes and standardises the results into a dictionary, Matches items between dictionaries and then ...
Jordan's user avatar
  • 21
2 votes
2 answers
77 views

Hash table implementation in C for a simple table record

I have a requirement to implement this simple table from one of the DVB S2X standards. The table is relatively small that contains no more than 28 rows. I need to use the key for the table as the ...
Inian's user avatar
  • 159
4 votes
1 answer
525 views

A Basic HashMap (Python)

A hashmap is a data structure that implements an associative array abstract data type using keys and values and has a hash function to compute an index into an array, from which the desired value can ...
Emma's user avatar
  • 3,477
2 votes
0 answers
760 views

Solution to 3Sum problem on Leetcode using HashTable

The problem of 3sum is described as: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero....
Giang Nguyen's user avatar
1 vote
0 answers
108 views

Building maps for Dgraph integration tests in Java 8

I want to refactor this in Java to reduce my code duplication. ...
devinbost's user avatar
  • 119
6 votes
1 answer
95 views

Distinguish between different types of log items in a dictionary by their key

My logging adapter is using a dictionary for storing data that is passed from middleware to middleware. It is a one-liner: ...
t3chb0t's user avatar
  • 44.2k
1 vote
0 answers
507 views

Rust book ch 13 Closures + HashMap exercise

So the exercise is as follows: Try modifying Cacher to hold a hash map rather than a single value. The keys of the hash map will be the arg values that are passed in, and the values of the ...
Ahmed Masud's user avatar
3 votes
1 answer
55 views

Validating partially filled objects

The following classes are a simplification of an auto-generated code of an ORM (targeting Microsoft's Dynamics CRM): ...
HelterSkelter's user avatar
4 votes
1 answer
1k views

Hash table implementation in Python

I wrote an implementation of a hash table in Python. This implementation uses chaining for handling collisions, based on lists. I also use an expansion/shrink factor of 2. The expansion is done ...
sojal's user avatar
  • 41
4 votes
3 answers
229 views

Consolidating a dictionary from nested dictionary

Currently learning from "LPTHW - Zed Shaw" and "Automating the boring stuff". There is a nested dictionary of the type ...
Prasad's user avatar
  • 41
0 votes
1 answer
730 views

Linked HashMap in C

I was looking for comments (on performance and general implementation) on the following Linked HashMap implementation in C: ...
DemCodeLines's user avatar
10 votes
3 answers
3k views

Yet another hash table in C

Will be very grateful for thoughtful code review. I needed hash table (again) and I wrote one. Code here is here or inline: ...
Leo's user avatar
  • 201
3 votes
1 answer
2k views

Moving an element from one unordered_map to another

This code moves one element from one unordered_map to another. I would like to ask if my code below can be improved. ...
Zack Lee's user avatar
  • 322
6 votes
0 answers
1k views

Recursive conversion from ExpandoObject to Dictionary<string, object> #2

Because my original question was lacking many details, I have been advised to ask a new question. I will repeat the important parts of the original question and add examples etc to hopefully make it ...
Joelius's user avatar
  • 355
5 votes
4 answers
5k views

Recursive conversion from ExpandoObject to Dictionary<string, object>

For my blazor library which is a modification of this awesome library I have to convert an ExpandoObject into a ...
Joelius's user avatar
  • 355
1 vote
1 answer
47 views

tablename alias in attribute name

I have dataframe like this: ...
elisa's user avatar
  • 185
0 votes
2 answers
5k views

Get value from a dictionary contained in a dictionary

I have an API that returns a dictionary of dictionaries. I currently have this code to access the value of the dictionary, but it looks like a code smell. Is there a better way to structure this? <...
Harry Mumford-Turner's user avatar
3 votes
2 answers
245 views

Pull-up sequence accumulator counter

I wanted to create a function describing a sport game called "Leader". The idea is that you make as many push-ups as you can, increasing each repetition by 1 and as you reach your maximum, each next ...
debrises's user avatar
  • 135
4 votes
1 answer
101 views

Iterable hashtable implementation in C

I'm just finished my version of iterable hashtable. I want to review code in general (code style, data structures, remarks about the algorithms) and I have some questions: I don't know how to ...
oss's user avatar
  • 44
11 votes
3 answers
2k views

Find the common ancestor between two nodes of a tree

Here is my code in Python for to find a common ancestor between two nodes in a particular tree. This is a question from Cracking the Coding Interview that I decided to implement on my own. No one has ...
SDG's user avatar
  • 213
3 votes
1 answer
169 views

Hashing array of strings as Merkle tree in one function

I want to hash an array of strings into one hash as shown on scheme on the image below. But I do not want to implement some class based Merkle tree. It's just a simple function. Is this a good ...
Michal's user avatar
  • 131
3 votes
0 answers
2k views

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
rickmanalexander's user avatar
4 votes
1 answer
400 views

LeetCode: Intersection of two arrays ii C#

https://leetcode.com/problems/intersection-of-two-arrays-ii/ Please review for performance, I am having a problem with using TryGetValue, if someone can explain how this can be used in here. Given ...
Gilad's user avatar
  • 5,321
5 votes
1 answer
748 views

Hashtable implementation in C for generic values

I am trying to implement a hashtable that supports character keys and can return any type of value contained in a struct as long as it contains as long as it contains ...
twodee's user avatar
  • 220
3 votes
1 answer
320 views

Building nested dictionaries to dump it to .json later

I am looking for some way to improve my code. It works but it doesn't look good and I am almost sure that lot of Best Practices rules are violated. The ...
jbb's user avatar
  • 31
10 votes
2 answers
1k views

Multi Key dictionary implementation

Description I had to create a dictionary structure where one value can be referenced by several keys. For example the keys a, b...
Opsse's user avatar
  • 287
7 votes
3 answers
678 views

Finding dictionary keys whose values are duplicates

I currently have a dictionary (Duplicate_combos) that has a unique identifying number for the key value and the value is a list with two elements, a company code ...
Ben Naylor's user avatar
5 votes
0 answers
84 views

Finding duplicates in an array using C [closed]

I came across a problem on LeetCode. There is an input array of integers. I need to find out if there any repeating integers, then return true else false. So, I tried using a hashtable library ...
hago's user avatar
  • 333
2 votes
0 answers
74 views

Coding Challenge Solution - Find Number of Elements in a range in \$O(1)\$ with preprocessing

Overview This is my solution to the following Coding Challenge - Find Num of Elements in a Range in \$O(1)\$ with Preprocessing - Given an array and max element in the array, find the number of ...
Nicola Bernini's user avatar
5 votes
2 answers
2k views

Splitting an amount of money equally between a group of people

I'm building a clone banking app at the moment, and one of the things I'm trying to do is add Split Transaction (which can then be shared with a set of friends paying a given amount each). Initially, ...
ADB's user avatar
  • 153
8 votes
3 answers
6k views

Python program to find the most frequent letter in a text

Given a text like "Hello World!" the program outputs the most frequent letter, in this case the "l". If there are two letters with the same frequency, it outputs the first in alphabetical order, for ...
Yone's user avatar
  • 657

1
3 4
5
6 7
19