JavaInterview | JVM , JUC , collection , computer | Microservice library
kandi X-RAY | JavaInterview Summary
kandi X-RAY | JavaInterview Summary
JVM, JUC (high concurrency), collection, computer network, database, MySql, Redis, workflow (Activiti), rule engine (Drools), Spring, SpringCloud, Mybatis, Git, Docker, Utils, Linux
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of JavaInterview
JavaInterview Key Features
JavaInterview Examples and Code Snippets
Community Discussions
Trending Discussions on JavaInterview
QUESTION
Given a list of strings ["abc", "abcdb", "gggh", "klsrtabcabc", "118*90", "ggggggggggggggggggggggggggggggggg"]
Return words which contain all letters from [a,b,b,c]
.(This means words with, at least, 'a' one time, 'b' two times, and 'c' one time)
Answer: "abcdb", "klsrtabcabc"
This is the hashmap algorithm for this
Build a character frequency map from the list of required characters. E.g. for
[a,b,b,c]
you end up with{a=1, b=2, c=1}
Iterate the list of strings:
- Build a character frequency map from the string. E.g. for "klsrtabcabc" you end up with
{a=2, b=2, c=2, k=1, l=1, r=1, s=1, t=1}
- Check if string has at least the required number of characters. E.g. since a: 2 >= 1, b: 2 >= 2, and c: 2 >= 1, the string is selected.
- If selected, add the string to the result. 3. Return the list of results.
I converted the first step into java code as shown as below, can anyone help me with step 2 and 3?
...ANSWER
Answered 2020-Aug-04 at 16:13Ideally you should try the steps 2 and 3 and come to SO when you are stuck with an issue and you can't find an answer. For now, I will give you my approach - Just a pseudocode:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install JavaInterview
You can use JavaInterview like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the JavaInterview component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page