Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
3 votes
2 answers
300 views

A View over java.lang.String - improved take II

(This post elaborates on A string view over a Java String.) This time, I have incorporated both the great answers in the previous iteration: https://codereview.stackexchange.com/a/293506/58360 by ...
coderodde's user avatar
  • 29.8k
5 votes
2 answers
544 views

A View over java.lang.String

(This post has continuation at A string view over a Java String - improved take II.) This time, I have a simple string view class for faster operation on substrings in actual string objects: ...
coderodde's user avatar
  • 29.8k
3 votes
1 answer
176 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 ...
coderodde's user avatar
  • 29.8k
4 votes
2 answers
124 views

(Another) text formatting method with word wrapping in Java

Please take a look at my code for (simply) formatting/wrapping a text. Is there something to improve? Here are the properties the method should have: (updated) Every space character (i.e. ...
Tobias Grothe's user avatar
3 votes
3 answers
156 views

Redouble each occurrence of char recursively, and add n

In following of this question, I would like to have a second review. The exercise is to write a recursive method that takes a String and a ...
Tobias Grothe's user avatar
4 votes
1 answer
272 views

Print columns of text without hard coding the width (attempt 2)

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
3 votes
1 answer
121 views

Print columns of text without hard coding the width

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
-2 votes
1 answer
401 views

Number Plate Generation Program

I wrote a number plate generation program. The program generates number plates for a car registered with a specific Memory Tag and on a specific date. Number plates use the following format: (2 letter ...
kmvfkmfv's user avatar
1 vote
3 answers
82 views

FileIO lines to String Converter

I think I made a good FileIO object because I can simply copy-paste whenever I need, however I wonder How I can improve my code. This code takes file path of the target file and turns every line to ...
ekan123's user avatar
  • 13
2 votes
1 answer
180 views

An evolutionary algorithm written in Java to crack an XOR cipher

Alright. So TryHackme is a website that tries to teach hacking with hands on labs. They have a room called JVM Reverse Engineering where the user gets to reverse engineer Java apps, and in particular ...
Aleksey's user avatar
  • 173
4 votes
2 answers
1k views

Add a number to a file name if does not exist or increase the number if it exist

I'm currently working on a solution to add a number to a file name if the number does not exist or increase de number by one if the number exist. For instance if you input "filename.jpeg" ...
Mario's user avatar
  • 41
4 votes
6 answers
1k views

Reverse string with identical spaces as in original String using Java

This is interview question Reverse string with identical spaces as in original String using Java For example Original String : best in the world and is greatest and is making sure the world goes well ...
Sreedhar Danturthi's user avatar
3 votes
5 answers
561 views

Frame Strings that contain newlines

I have an application where I need to highlight some information that is printed to the console, so I wrote some static library methods which do that. I tested for bugs. Is my code clean and ...
Dexter Thorn's user avatar
  • 2,174
2 votes
1 answer
129 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: ...
RWLKfjs's user avatar
  • 23
7 votes
2 answers
695 views

Concat two strings by slicing them with same length

I want to concat two strings, by sub-stringing each one with same length, and concatenation should happen like I mentioned below for suppose, I have str1 = raines, str2 = bowls, and LENGTH as 2, then ...
raj's user avatar
  • 71
0 votes
2 answers
149 views

New String similarity algorithm (java)

Recently I have been developing a library for Java which provides utility functions for arrays, strings, etc.. While researching string similarity algorithms, I managed to write one of my own. I am ...
Temps's user avatar
  • 49
-2 votes
2 answers
407 views

Fastest string search algorithm invented by me. It is called ""Choudhary String Search Algorithm""

I have invented the fastest string search algorithm. It is called ""Choudhary String Search Algorithm (choudharyStringSearchAlgorithm)"". I have compared my algorithm with Brute ...
user avatar
1 vote
1 answer
214 views

Finding longest palindromic substring in a string (gives TLE on leetcode)

I'm solving the Longest Palindromic Substring problem on LeetCode. And here's my final submission: ...
Joe D's user avatar
  • 113
0 votes
1 answer
542 views

Better way to format a query string in Java

description I'm using influxDB, I need use Java to generate a query command. The TestingTag struct maybe missing 0-3 fields. code: ...
leaf_yakitori's user avatar
1 vote
2 answers
227 views

Parsing words from string

I am learning Java, so I am beginner. I know I can do this with split function but I want to improve my algorithm knowledge. I will be glad if you help me. Thanks. inputStr variable is contains the ...
Mestedepsu's user avatar
7 votes
1 answer
339 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 ...
isanma's user avatar
  • 73
4 votes
1 answer
327 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 ...
Deepeshkumar's user avatar
0 votes
1 answer
914 views

Fastest string search algorithm

I have invented the fastest string search algorithm. Can someone prove that it is not fastest? I am not considering worst case scenarios. The algorithm can be found here: https://sourceforge.net/...
user avatar
0 votes
1 answer
96 views

Rabin karp substring search

Below is the Rabin Karp implementation. I am not so sure about it, and there is no where that I can check whether this code really works or not. It will most helpful for extra set of eyes if whether ...
Leprachon's user avatar
2 votes
2 answers
856 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
4 votes
8 answers
1k views

Are two strings anagrams?

My code passes all the given test cases. I would like to know a better way to to write the code. Such as a more efficient algorithm for checking if two strings are anagrams. ...
Akshay Saambram's user avatar
3 votes
3 answers
942 views

Longest common prefix for set of strings

Question: Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example : ...
DntFrgtDSemiCln's user avatar
4 votes
3 answers
560 views

Censoring emails in Java

I'm working on a simple method that would censor emails (GPDR stuff) so they won't show the full name of a user, with 1st character, optional dot, 1st character after the dot and whatever is left ...
Jack_Russell's user avatar
1 vote
2 answers
1k views

URLify a given String - replace spaces with %20

I have written a code to replace all spaces in a String with %20. ...
salazarin's user avatar
  • 113
3 votes
1 answer
117 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 (...
qwerty's user avatar
  • 361
3 votes
1 answer
77 views

A Sub-string Extractor Implementation with Given Vocabulary Words in Java

This is a follow-up question for A Sub-string Extractor Implementation with Specific Keywords in Java. As AJNeufeld's answer mentioned, the test case ...
JimmyHu's user avatar
  • 5,510
4 votes
2 answers
85 views

A Sub-string Extractor Implementation with Specific Keywords in Java

I am trying to implement a Java version sub-string extractor with "start keyword" and "end keyword" and the extracted result is from (but excluded) the given start keyword to (but ...
JimmyHu's user avatar
  • 5,510
1 vote
3 answers
103 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 ...
Jason p's user avatar
  • 11
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
8 votes
3 answers
830 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 ...
Nicholas Whitley's user avatar
7 votes
4 answers
3k views

How can I efficiently manipulate digits in a string without using RegEx in Java?

I am reading a book with different quizzes about coding interviews. Please implement a function that increments a string based on the rules below: It should take the string of unknown length and ...
Pitto's user avatar
  • 829
6 votes
4 answers
2k views

First non repeated character

Problem Statement : Print the first non repeating character in a string. Example : In the string somecharsjustdon'tliketorepeat, ...
Omkar76's user avatar
  • 163
2 votes
1 answer
161 views

Converting an integer to a hexadecimal string representation in Java

I have rolled my own Java method for converting ints to the hexadecimal Strings: ...
coderodde's user avatar
  • 29.8k
6 votes
2 answers
2k views

Hide certain email characters

Hide email characters: When email only has one letter then just cover that letter with the * symbol e.g. *@gmail.com When ...
Artjom's user avatar
  • 103
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....
Arya's user avatar
  • 21
4 votes
3 answers
681 views

Checking if a string contains all unique characters

I am currently reviewing CTCI(Cracking the Coding Interview) The question is asking me to implement an algorithm which checks whether the characters in a string are all unique however they do not want ...
E-SetPrimeEpsilon's user avatar
-3 votes
1 answer
53 views

I am trying to save a string to a MYSQL table from a radiobutton in java/Android studio [closed]

I am trying to save a radiobutton string if it clicked. I am making a survey where I need to save a "yes" or "no" into a MYSQL table using volley. I am having a little trouble ...
Connor Daly's user avatar
3 votes
3 answers
180 views

Optimize Memory Java String Array

I was trying to solve one programming challenge : First input is a list of connections which is made of pair of IPv4 address. Each IP has its own state which starts with false, each connection also ...
Learner's user avatar
  • 133
4 votes
1 answer
455 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 ...
Simmant's user avatar
  • 155
1 vote
1 answer
163 views

Encasing a string in double quotes

I need to add some characters to a String before using it for an API call. The idea is to add a " char both at the beginning and at the end of the String, to make ...
goelakash's user avatar
  • 167
3 votes
1 answer
87 views

Listing words from text, provide lines where appears, count them

I applied for Junior Java Developer in some company. Got a task:"Listing words (without duplicates) from text, provide lines where appears, count them." Output should looks like: Alphacoronavirus - 3 ...
Konrad's user avatar
  • 33
2 votes
1 answer
83 views

Code for adding a user to the database

I have a code that adds a user to the database, getting the username from the dialog.My fragment implements the interface with the onInputSend method, which is called by the dialog when the user ...
Destroyer's user avatar
  • 459
4 votes
5 answers
2k views

Convert Integer to String without using Java API library

I have written a Java program that converts an integer to String digit by digit and concatenate them together using the + operator without touching the Stock Java API library. I like to have feedback ...
mvr950's user avatar
  • 297
4 votes
3 answers
852 views

Vowels and consonants in Java-exercises with strings

I feel like my code is too messy-Im looking for possible way to make it more readable/shorter. Goals: 1)Get three strings from user input. They have to be the same length. a)First must contain only ...
AdamK's user avatar
  • 35
7 votes
4 answers
2k views

Determine if a String has a mirroring head and tail

Problem statement: Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or more characters at the very begining of ...
Anirudh's user avatar
  • 872

1
2 3 4 5
13