All Questions
125 questions
4
votes
3
answers
556
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 ...
3
votes
1
answer
187
views
Snail matrix in Java - version III (generalizing)
Once again, in the previous version,
Alexander Ivanchenko helped me with his awesome answer.
Now, I have improved the toString() and, also, generalized the class ...
2
votes
1
answer
133
views
Related to DSA: Find longest common prefix
The objective of below code is find longest common prefix from trie DataStructure which is written in Java.
Code:
...
7
votes
1
answer
346
views
Create tweet threads from String in Java
I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The ...
4
votes
1
answer
345
views
A different approach to string pattern matching algorithm
Although there exists the most efficient "Knuth-Morris-Pratt" algorithm of string pattern matching. I tried to achieve the same result with a different approach. But I am not sure about it's ...
3
votes
1
answer
128
views
Substring search in Java
I am trying to make an algorithm that will find the index of a given substring (which I have labeled pattern) in a given String (...
1
vote
3
answers
119
views
Identifying indices of non-delimited characters in a string, supporting greater than 1 length of delimiters
The code below takes a string that potentially contains a true match for a delimiter. There can be multiple delimiters located anywhere in the string. We need to obtain the indices that are not a ...
4
votes
1
answer
468
views
Hamming distance implementation in Java
I'm exploring String relativity and comparison techniques, and I found Hamming distance algorithm in my search so I give a try to implement that approach in Java and below I'm sharing my ...
3
votes
1
answer
256
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
273
views
LeetCode Reverse Words in a String without using any java library
The following problem is from LeetCode:
Given a string, you need to reverse the order of characters in each
word within a sentence while still preserving whitespace and initial
word order.
...
3
votes
2
answers
130
views
Reverse chars of each word in a string
An algorithm to reverse characters of each word in a sentence.
What would be your concerns regarding the following solution?
Example input: "I love New York"
output: "I evol weN kroY"
...
2
votes
1
answer
110
views
Find the number of all specific substrings in a string
I would like to ask a code review regarding a concrete exercise. Let's suppose I have to get the number of all specific substrings in a string.
We call something specific if any of these conditions ...
2
votes
3
answers
221
views
Armstrong number generator
This is my code to generate all possible Armstrong numbers between the two given numbers. The logic uses string instead of integer to separate the digits to optimize the code.
...
-2
votes
2
answers
196
views
ArmstrongNumber checker
This is my code written to check whether a given number is armstrong or not . but the logic differs from the conventional logic of using integer and separating its digits and calculating , instead i ...
3
votes
2
answers
1k
views
Counting the number of ways to decode a string
I am working on problem where I need to decode a string:
A message containing letters from A-Z is being encoded to numbers
using the following mapping:
'A' -> 1
'B' -> 2
...
'...