Skip to main content

All Questions

Tagged with
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 ...
CodeCrusader's user avatar
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 ...
user12218554's user avatar
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. ...
user2652379's user avatar
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 ...
Rob's user avatar
  • 63
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 ...
a-ina's user avatar
  • 305
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. ...
Tishy Tash's user avatar
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 ...
abc556's user avatar
  • 11
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[] ...
LuminousNutria's user avatar
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 ...
JSextonn's user avatar
  • 686
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 ...
edwin's user avatar
  • 121
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'...
dfrey's user avatar
  • 31
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 ...
Yuki1112's user avatar
  • 135
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): ...
John's user avatar
  • 213
2 votes
1 answer
1k views

Random string generation in Java

Can random string generation be faster in Java? Here is my current code ...
user1870400's user avatar
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. ...
enon's user avatar
  • 387

15 30 50 per page
1
2 3 4 5
7