All Questions
40 questions
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 ...
8
votes
3
answers
835
views
Creating Two-Dimensional String Array for Plane Seats
I'm creating a ticket reservation system in Java, I want to use a Two-dimensional String array for managing the seats. I have enums that hold the plane model and the amount of seats available so the ...
2
votes
1
answer
2k
views
Add comma/and between string array in java
i get an array of authors from json response and i have to display authors name in TextView(android) in proper format like =>Viraj, Chetan and George R. R. Martin
my code work fine, but it's a mess....
3
votes
1
answer
385
views
Random String Chooser
I was tasked with creating the class RandomStringChooser that prints the strings in the passed array in a random order, based on the ...
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[] ...
6
votes
3
answers
384
views
Leetcode - First Unique Character in a String
Given a string, find the first non-repeating character in it and
return its index. If it doesn't exist, return -1.
Examples:
...
3
votes
2
answers
115
views
I/O-TxtFile Line Distance Program
I am trying to write a lab/program that loops through a .txt input file. Reads an entire line of data as a string, then splits that string into an array delimited by a space. If there are 4 items in ...
3
votes
2
answers
3k
views
Swapping pairs of characters in a String
Question: Write a program to swap pairs of characters of a String. In
case of odd number of characters last character should remain
unchanged.
Examples:
Input: HI
Output: IH
...
3
votes
3
answers
330
views
Search for names in a hard-coded list of contacts
I am currently taking a class at my local community college for java programming as well as trying to learn as much as I can on my own time. I would like your opinion on a program I wrote that would ...
3
votes
3
answers
34k
views
Print a String's even and odd indexes
I implemented this method and wanted to get suggestions and or improvements.
The objective of the method is to print the even and odd indexes of Strings contained within an array. Each set of indexes(...
10
votes
4
answers
13k
views
Replace ' ' Spaces in a URL with a '%20' - Coding Challenge
This was a small coding challenge proposed at my school. The problem is:
Given a string (or URL), replace the white-spaces inside of the string
with %20, but ...
5
votes
1
answer
744
views
Sequence Alignment of two Strings
I have some code which aligns the sequence of two strings, I am doing numbers just for my implementation.
I was wondering whether there are any performance enhancements I could make as the code ...
1
vote
1
answer
981
views
Method that remove duplicates from a list of words in Java [closed]
Today, I took a coding challenge with this question:
Given a List of Strings, write a method removeDuplicates that removes duplicate words from the List and returns an ArrayList of all the unique ...
2
votes
0
answers
115
views
With 2 sets of strings, find a string that can be constructed from either set
Given the following sets of strings:
are yo
you u
how nhoware
alan arala
dear de
I need to find a sequence that can be constructed by concatenating the strings ...
4
votes
1
answer
138
views
Practicing arrays with String class methods
I am a Spanish programming teacher in a vocational training course and we are studying arrays. In order to practice and to get the students familiarized with some methods of the ...