A data structure that uses a hash function to map identifying values, known as keys, to their associated values
0
votes
0answers
15 views
Web scraping spell checker
I've implemented a program that does the following:
Scan all of the words in a web page into a string (using jsoup)
Filter out all of the HTML markup and code
Put these words into a spell checking ...
3
votes
1answer
46 views
Website Spell Checker in Java - follow-up
After receiving some great feedback on my original program, I tried to implement everything that was shared and I just want to see if there's anything else that I can change to make my program clean ...
5
votes
2answers
74 views
Website Spell Checker in Java
I've implemented a program that spell checks a website.
Here is the idea that I have in mind:
Scan all of the words in a web page into a string (using jsoup)
Filter out all of the HTML markup and ...
4
votes
1answer
67 views
Find distinct combinations of four elements in an array that have a certain sum
The task is: Given an array A of size N, find all combinations of four elements in the array whose sum is equal to a given value K.
The specific requirements are:
The combinations must be distinct
...
7
votes
3answers
677 views
HackerRank “Ransom Note” challenge
I have solved the Ransom Note
challenge on HackerRank using JavaScript / ECMAScript 6. The challenge goes like this:
A kidnapper wrote a ransom note but is worried it will be traced back to him. ...
5
votes
0answers
86 views
An interval-map data structure
This data structure maps values from intervals of some type Key which satisfies LessThanComparable<Key> to values of some ...
4
votes
1answer
55 views
3
votes
2answers
40 views
Hash Table insertion linear probinig
My code is working fine Could you please review how I can make it more accurate and efficient?
...
4
votes
2answers
97 views
Parse a JSON file in Java
I am using Java to parse a JSON file into a hash map so that i can search by typing a date and then get the cost, tax and profit for that date.
So that if i write:
...
6
votes
3answers
126 views
Concurrently reading a Map while a single background thread regularly modifies it
I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside ...
5
votes
1answer
50 views
Counting the occurrences of bank account numbers for SPOJ challenge
I am solving a problem on SPOJ and am currently unsatisfied with my submission time, given that my fastest time is 0.28s (which ranks me 123/5037) and the leading submission is 0.04s.
The problem is ...
8
votes
5answers
246 views
Validate input that maps int to enum
I've written the following enum and have added a function, fromValue that allows the caller to map given int into the enum value. I was wondering if the ...
2
votes
0answers
40 views
Spellchecker program is having issues due to vowel checking method
This program takes in a list of 275k or so words from '/usr/share/dict/words' and loads them into HashSet. It then takes in a list of 1000 words (taken from the dictionary and are scrambled (vowel ...
1
vote
0answers
32 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
113 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
71 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
37 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
52 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
60 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 ...
3
votes
1answer
103 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
17 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
220 views
4
votes
1answer
77 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
65 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
160 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
77 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
153 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
40 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
102 views
1
vote
1answer
40 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
30 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
137 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
88 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
53 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
88 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
188 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
55 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
151 views
Alternative to using Object and casting in a map
I have the following class which represents a set of properties.
...
2
votes
0answers
125 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
91 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
576 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
89 views
Bare bones implementation of Java HashMap
I've done a minimal implementation of a HashMap. Invite comments.
...
4
votes
1answer
128 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
410 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
928 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
69 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
552 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
23 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
974 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 [...