Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.
2
votes
Anagram checking implementation
Your use of the counting system using a HashMap is a functional approach to solving the problem, and algorithmically it's relatively good (has time complexity of \$O(N)\$). But, for a prolem like this …
3
votes
Accepted
Check Unique Chars in A String
I imagine for even reasonably large strings, it will be slower than your second option... which also has problems. …
4
votes
Accepted
Arrange lines of a text file
The most significant issues in your code are:
the handling of inputs.
the use of helper functions from the standard libraries.
The algorithm you have chose in is fine, and both other answer recomm …
4
votes
Accepted
Check if two strings are permutations of each other
Bugs
Your spec says the strings will contain ASCII characters, and, to me, things like spaces and punctuation -_!@#$%.... are all ASCII. …
2
votes
Accepted
Reinterpreting a string, treating < as a backspace character
In your use case, the depth of the stack is proportional to the length of the input string, and strings longer than a few thousand characters will cause an out-of-memory problem. …
7
votes
Accepted
Integer to binary using an old-school way
Functional extraction
Your method does not do toBinary, it does:
read input from user
convert to binary
print back for user
When you have methods that do multiple things it becomes hard to isolat …
5
votes
Write a method to replace all spaces in a string with %20
Your strategy of counting the spaces and then back-looping to shift the characters right (and replace spaces with %20) is good. The basic algorithm is probably as good as it gets as a character array …
5
votes
Accepted
Hex-string representation of a byte array
Your code is good. The CXF code has a bug, and is missing leading-zero values when the byte value is less than 16.
Your code can be improved, though. It's doing a lot more work than it needs to do ge …
4
votes
Accepted
String permutations
In your case, you are adding the strings to the bucket inside the loop inside the recursive function. I believe you should try to do that only at the "leaf" level of the recursion. …
6
votes
Accepted
Converting Morse Code
Debatable ... and a bug?
constructs like these are one of those things that personal-preference plays in to, but consider:
if (args.length != 1) {
System.err.println(args.length > 1 ? " …
2
votes
Accepted
Command called 'sprinkle'
Apart from what @AmirhoseINZif has answered, there are two other items that I feel are significant.
You pass in the file-name "test.txt" when you call the transformations, err = readLinesFromFile("t …
3
votes
Replacing multiple search strings simultaneously
For example - it is quite OK to throw a NullPointerException if one of the input strings are null when they should not be. An IllegalArgumentException for empty-strings is OK. … (strings).allMatch(x -> x == null || x.isEmpty());
}
That would be better as:
private static boolean anyNullOrEmpty(String[] strings) {
return ! …
7
votes
Find palindrome in a string
Which turns out to be \$\frac{1000^2}{2}\$ - or a half-million strings that you check.
Now, for each of those string values, you then check to see if they are a palindrome. … Presumably, for each of those strings, in the isPlaindrome method, you compare the string to the reverse of the string, which means checking each character again. …
10
votes
Creating a numeric phone keypad
The text-to-key problem is one that has multiple solutions. The Map solution is a good one, there's nothing wrong with it. There are two other algorithms that are good too. First, though, please conve …
7
votes
Accepted
Brute-force string generator
What you have implemented is a back-to-basics number-system in base 62 Your IntList List is a mechanism of having the equivalent of "units", "tens", "hundreds", except you are in base 62 so it's "unit …