All Questions
99 questions
4
votes
4
answers
430
views
Finding Special Parts in a Word
Task description:
Imagine you have a long word made up of small letters like "a", "b", "c", ancd so on. Let’s call this word a puzzle word.
We want to look at all the ...
2
votes
2
answers
866
views
Counting uppercase and lowercase characters in a string
I created two programs (one with JAVA8) to calculate the total count of uppercase and lowercase characters in given String. After checking the execution time JAVA8 is taking longer execution time than ...
9
votes
1
answer
1k
views
Generate unique random strings considering collisions
I'm coding a random strings generator. It's working, but I'm not sure if this is efficient.
...
3
votes
3
answers
160
views
Java regex and replaceAll to extract strings into objects
I have this method that creates book objects. I pass a list of strings (size 60000+) that contain the information of the book, the function then goes and extracts the information makes the book object ...
3
votes
1
answer
254
views
Knuth-Morris-Pratt algorithm in Java Finding substrings in a matrix
Problem
Given two matrices: a pattern p and a text t. Write a program that
counts the number of occurrences of ...
3
votes
1
answer
184
views
Left or right padding a string with the specified character
Can I improve performance of below method? Is there anything I need to optimize or any redundancy I need to remove to make it more efficient? It's a simple method used to pad strings by left or right.
...
1
vote
2
answers
290
views
Optimize printing massive strings to System.out with respect to time
I need to cut the time it takes to print a large string by ~50%.
I went from using s1 + s2 to using StringBuilder, and instead ...
5
votes
2
answers
1k
views
Find hamming distance between two Strings of equal length in Java
I have a private class that I want to be able to find the shortest Hamming Distance between two Strings of equal length in Java. The private class holds a char[] ...
2
votes
1
answer
229
views
String reversing x times
Inspired by CodeWars
We have a string s
Let's say you start with this: "String"
The first thing you do is reverse it: "gnirtS"
Then you will take ...
0
votes
1
answer
2k
views
Parsing messages with fixed-width fields into Employee objects
I'm writing a application that reads from a queue of messages from a legacy mainframe system.
Some characteristics of message in the queue:
Message from the Q is always fixed length plain text : 64 ...
3
votes
1
answer
251
views
Map Character to Characters Most Frequently Found With it (in list of strings)
For an interview, I was tasked with writing a program that consumes a list of strings, and produces a mapping between every character in the list, and the characters found most frequently with it (let'...
2
votes
4
answers
900
views
Split a string into a list of tokens
I have the following assignment that I succeeded in solving, but the code is very inefficient. I would appreciate if someone could show me a more efficient way, perhaps with substring. Note that I am ...
2
votes
2
answers
69
views
Longest substring with 2 unique characters in a given string at linear time
This is my java implementation based on the solution of Aasmund Eldhuset here.
Please give your opinion on my code (correctness, efficiency and coding conventions):
...
2
votes
1
answer
1k
views
Random string generation in Java
Can random string generation be faster in Java?
Here is my current code
...
2
votes
2
answers
97
views
Method that receives a hexadecimal string and returns a formatted matrix of those values
This method is part of a larger project and comes after encoding ascii characters into hexadecimal values, so it assumes the parameter is always a valid hex string.
...