Tagged Questions

A string is a sequence of zero or more characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

learn more… | top users | synonyms (1)

2
votes
2answers
39 views

Parse a value to a given datatype

For our (internal) automated test project, I am writing a part where parameters can be passed to an SSIS Package before it gets executed. The tester delivers the parameter name, value and desired ...
2
votes
2answers
80 views

String compression using repeated character counts

Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become ...
2
votes
2answers
65 views

Skipping whitespaces when reading file

In reading a file, I found blank lines (even at the bottom) crash the program. To fix this, I've added the following if statement: ...
3
votes
1answer
82 views

Getting information of countries out of a website that isn't using consistent verbiage

From this website I needed to grab the information for each country and insert it into an Excel spreadsheet. My original plan was to use my program and search each website for the text and later ...
3
votes
1answer
38 views

Changing the prototype of the String object

Are there any pitfalls in changing the prototype of the String object? I'd like to change the word substr to "left": ...
1
vote
2answers
48 views

“The Love Letter Mystery” - storing and comparison of strings

The problem goes like this. Change the strings provided by user to form palindromes. To do this, 2 rules are: (a) Reduce the value of a letter, e.g. Change 'd' to 'c', but cannot change ...
4
votes
3answers
69 views

Finding strings inside of other strings in order in C

A question on Stack Overflow recently intrigued me to the point of me implementing the functionality in C. Can you critique this algorithm and tell me what is good and bad about it? This program will ...
8
votes
2answers
84 views

Optimizing String combinations in Java

I need to obtain all combinations of a String of length k from the given elements. For example, for ...
5
votes
1answer
163 views

Logging with date in Java

I write my log messages in JTextArea. Each message should have a time added. I created a following method: ...
6
votes
4answers
764 views

String case reverse function in C++

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Let's get critical here. ...
4
votes
4answers
120 views

String case reverse function in C

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Besides documentation, in particular, any thoughts on the type ...
5
votes
4answers
42 views

Trimming fgets(): strlen() or strtok()

After a successful fgets(buffer, ...), it is often desirable to trim a potential End-of-Line \n. Of the following 2 methods, ...
12
votes
6answers
545 views

Check for balanced parentheses

I was given an assignment to check for balanced parentheses from an arbitrary string where parentheses are defined as (, [ or { and their respective "closing" ...
11
votes
2answers
142 views

StringBuilder in VBA

In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To ...
2
votes
2answers
56 views

Splitting a Multi-FASTA file into individual files

I have written a program to split a Multi-FASTA file into individual fasta files. ...
3
votes
2answers
159 views

Generating character permutations

I want to generate a 'dictionary' containing all 8 character permutations of upper-case letters such that the output file looks like: ...
7
votes
3answers
515 views

Concatenate two strings

I am learning C and wrote a function to concatenate two strings in C. Please let help me improve it. ...
2
votes
4answers
276 views

Parsing a string to get the values of certain attributes

I have written a small method that extracts certain information from a string. An example of such a string is ...
13
votes
5answers
267 views

Fastest way of removing a substring from a string

Taking a break from my C++ series, I recently reviewed the code in this question. I ended up writing my own separate derivation of the function so that I could remove all of the substrings from a ...
6
votes
5answers
582 views

Given a String, return a boolean if it is a number

Yesterday in an online interview, the interviewer asked me this question: If I give you a string, you have to return if a string is number or not. You are not allowed to use any parse function ...
6
votes
2answers
183 views

Trim a string to a given start and end

Are there any other more exotic ways ... or is this one just good? ...
1
vote
2answers
65 views

Reverse Message Program

...
3
votes
1answer
89 views

Example String Class in C

I wrote this small example piece of OOP being implemented in pure C. I wanted it to be reviewed for the following points: Portability Performance And especially Usability "How does it look" ...
5
votes
4answers
542 views

Arranging words in sentences alphabetically

For an online contest whose problem is here, I wrote some code. In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the ...
3
votes
2answers
98 views

Longest Common Subsequence and Longest Subsequence Palindrome

The following code computes: The longest common subsequence between two strings, where a subsequence of a sequence does not have to consist of contiguous elements of the sequence. The longest ...
0
votes
0answers
39 views

Longest increasing subsequence and common substring

I wrote a program that computes longest increasing subsequences and common substrings. Can you please suggest more elegant and eloquent ways for this program? (Perhaps better ways to represent a ...
3
votes
1answer
99 views

Finding the longest unique sub-string in a string

I recently interviewed with a company for software engineering position. I was asked the question of finding the longest unique sub-string in a string. My algorithms was as follows: Start from the ...
0
votes
1answer
46 views

Converting integers to strings

I drafted a method that I intend to use to convert integers to strings. Is there a way to make it faster? Are there any "simple" changes I could make to improve its performance? This cannot be done ...
1
vote
2answers
94 views

Most common words in a text file

I've made a program that outputs you the most common word in txt file. Does anybody know how to optimize it so that it would work for bigger files and run faster? ...
2
votes
2answers
110 views

Evaluation of a solution for Run-length encoding algorithm

I wrote an answer for the following question and wondering if there is any better approach to it. Using the Java language, have the function RunLength(str) take ...
8
votes
4answers
788 views

Pig Latin in Java

I've done my second application in Java now. I want to know if: This code is efficient This code can be written in a shorter and faster way Any flaws Any misuse or better use of concepts Main ...
1
vote
1answer
200 views

Reversing a String in Java

I'm new to Java and I want to know if this code is efficient, and if there a shorter and faster way to reverse a string. ...
8
votes
3answers
154 views

Basic string compression counting repeated characters

My task was to implement a method which performs basic string compression by counting sequences of repeating characters. Given "aaabbbccc" it should return ...
5
votes
3answers
71 views

Windows forms set saved groupbox location settings

I have a Windows form that when a user moves some groupboxes around, before the application exits, it saves those X and Y coordinates into a MySQL database (with a bit of added text to identify which ...
4
votes
3answers
175 views

Prefix and suffix detection algorithm

I have written an algorithm intended to find prefixes and suffixes in arrays of strings. I would like to get opinions/suggestions/reviews on the code I wrote (specially cases in which my code would ...
11
votes
5answers
879 views

Finding longest word in a string

I was working on a problem from Coderbyte. The challenge was to write a function that takes in a string and returns the longest word in the string. If two words are the same size then it asks to ...
3
votes
1answer
191 views

Removing whitespaces in a string

I wrote this function to remove whitespaces in strings. Please help me improve it. I intended to use the function for a Big Integer ADT. ...
4
votes
1answer
183 views

Find repeated substrings of length 3 in a string

The following method receives a string and finds all occurrences of repeated substrings with a length of three characters, including spaces. Is this a good approach? ...
0
votes
1answer
57 views

Reading/writing null-terminated strings from socket

I need to handle C style ('\0' delimited) strings from/to a socket and came up with this as a first attempt: ...
7
votes
3answers
1k views

Replace each whitespace in a string with “%20”

My implementation: ...
6
votes
3answers
606 views

String compression implementation in C#

I wrote a method that reduces a string like aabcccccaaa to a2b1c5a3 My implementation: ...
3
votes
2answers
98 views

Implementing faster StringBuilder that only works with ASCII strings

I wrote a StringBuilder that works only with ASCII strings. the current append performance is almost identical to BCL StringBuilder append performance. I want some tips on how to make it faster, and ...
3
votes
2answers
98 views

Writing strings to a file

This opens a file and writes 5120 times a string to it, and if the file doesn't exist it creates a new file. The name of the file and the string are chosen randomly. I would like to know if there is a ...
2
votes
2answers
105 views

Determining the number of vowels in each word from a file

I'm 5 weeks into my first C++ class. I'm curious about how this code could be improved, more streamlined or simply things that I could/should have done better. The project was: Read from a .txt ...
4
votes
1answer
61 views

Regular expressions - match only specified string length

I'm learning regex. Here I'm checking a string of type aA1 but want also to check it is only 3 characters long. Is there a better way of doing it please? ...
8
votes
4answers
129 views

Align Strings for Output

I wrote a class which can format input so that it is properly aligned. I'm interested in all suggestions (regarding structure, usability, style, naming, comments, etc). I'm especially wondering ...
4
votes
2answers
80 views

String representation of Tree

I have a Tree class, defined as follows: ...
9
votes
6answers
2k views

Reversing a String using Stack

Is this code okay? ...
5
votes
2answers
219 views

Re-arrange a string into a { consonant, vowel, consonant, vowel … } sequence

I was prompted to give someone advice about the following problem: Given a string with equal amount of vowels and consonants, re-arrange it so that it follows the sequence { consonant, vowel, ...
3
votes
3answers
84 views

Multi-replacement in a string, independently and prioritized

I need a shorter way to do this. input: an ordered list of string pairs L; and a string s task: for each pair ...