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)

6
votes
1answer
40 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
46 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
148 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
506 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
260 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 ...
10
votes
3answers
118 views
+50

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
563 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
173 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
62 views

Reverse Message Program

...
3
votes
1answer
86 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
521 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
87 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
36 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
94 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
45 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
87 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
101 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
772 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
125 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
62 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
164 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
861 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
184 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
179 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
55 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
585 views

String compression implementation in C#

I wrote a method that reduces a string like aabcccccaaa to a2b1c5a3 My implementation: ...
3
votes
2answers
93 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
97 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
93 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
59 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
127 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
76 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
214 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
80 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 ...
3
votes
1answer
71 views

Count frequency of words in a string returning list of unique words sorted by frequency in descending order

I have the following solution but I am trying to optimize it to run in O(n) time, any thoughts? I first split the string removing any non-alphanumeric characters, then split the words using spaces ...
1
vote
1answer
32 views

Using Regexp to select the date from a string [closed]

I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is ...
9
votes
3answers
119 views

Ugly workaround to get the vbext_ProcKind of a procedure is breaking encapsulation

This is a follow up to Extending the VBAExtensibility Library. It turns out that code had a really nasty bug. Anytime vbeProcedure.StartLine got called, I was ...
6
votes
3answers
558 views

Comparison between strings

This review is very short and very straight-forward. There are two people in the team and the checked-in code looks as follows. ...
3
votes
3answers
308 views

Determine if a string has all unique characters

I'm practicing algorithms (for future interviews) while learning about Big O notation and was wondering if there's a faster or more optimal way of writing an algorithm to see if a string has all ...
5
votes
1answer
77 views
3
votes
7answers
119 views

Optimization of a String maneuvering oriented program

I've got an interview coming up for which the following is a prospective question: Given 2 strings, for instance: John Lennon Paul ON delete every character from string 1 which ...
2
votes
1answer
79 views

Encoding and decoding exercise

I was issued the following coding challenge from a company to write an encoding and decoding function: Encoding: This function needs to accept a signed integer in the 14-bit range [-8192..+8191] ...
8
votes
2answers
83 views

Fixing double arithmetic errors

I am trying to account for the errors in double arithmetic in a C# program I am writing, and came up with this first solution that seems to work well for most cases: ...
8
votes
1answer
76 views

Compare the index of each char in a string in an alphabet array to a range of numbers

I saw this codegolf challenge and I set out to try and write a solution for it. I'm nowhere near an expert codegolfer (or programmer), but it was an interesting exercise. Now I'm wondering how to ...
11
votes
4answers
583 views

Split camel cased/snake cased String

I want to implement a method which, given some camelcased or underscored String, will return a list of separate words that make up this ...
1
vote
0answers
37 views

Comparing different string-matching functions

Here is a problem came from codingbat: Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since ...
1
vote
0answers
49 views

A function for parsing words from a string without using whitespace

I'm trying to parse words from a badly garbled text file that contains many repeats. It's about 100k characters in length and was formed from joining many substrings in alphabetical order. I'm ...