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.
2
votes
1answer
36 views
Using TAGS with <script> on your websites
This function creates a series of links at a desired destination by the usage of a premade tag system.
Usage:
createMyTAGS_DATA passes in a single line of all ...
1
vote
3answers
104 views
Reversing a string in place without using iteration in C
This is function for reversing a string in C using recursive calls:
...
13
votes
6answers
1k views
Determining whether two scrambled strings are equivalent
I was able to complete the problem doing it in this manner, but I would assume there has to be an easier way.
Sample input: abc, cba
Output: ...
-2
votes
0answers
27 views
3
votes
2answers
35 views
JavaScript/jQuery string handling
Recently I wrote some code to take two arrays of data and create a title. Each array could have 0-n elements. However, the multiple if statements seem messy to me. ...
4
votes
2answers
100 views
Testing whether a given string has unique characters
Here is my code which tests whether a given string has unique characters. The function is_unique which does a linear search for each character in the string is ...
0
votes
0answers
25 views
Reading string separated by spaces into vector in C++ [on hold]
Heres what my test.txt looks like:
18 19 20
21 22 23
22 23 24
23 24 25
24 25 26
25 26 27
28 29 30
29 30 31
I want to read in the integers in test.txt as strings ...
7
votes
1answer
56 views
Karp-Rabin with bitwise hash
As a Rags-to-Riches re-implementation of the Karp-Rabin question here, from @tsleyson, I thought it would be interesting to understand the algorithm better, and to use bitwise-shifting instead of ...
5
votes
3answers
67 views
Karp-Rabin String Matching, Part 2
Part 1 is here. I wrote a Java implementation of the Karp-Rabin semi-numerical string matching algorithm. I incorporated the suggestions of @fge and @maaartinus from the other question into my new ...
4
votes
3answers
182 views
Splitting and printing comma-separated values
I stumbled upon a question on SO asking how to split a comma-separated string into individual values.
Since it's been a while since I've had any good reason to write C I'd like to ask for some ...
0
votes
1answer
55 views
String search & replace in C
I created a function to do that, and I want to know if there is a problem I'm overlooking about it ..
...
5
votes
4answers
535 views
Check if two strings are anagrams
I'm doing some practice questions from the book Cracking the coding interview and wanted to get some people to review my code for bugs and optimizations.
Question:
Write a method to decide if two ...
4
votes
1answer
50 views
Add spaces before uppercase letters
I'm trying to convert some very simple C# string utility functions to F# as a learning exercise. Ignore the fact that the C# version is implemented as an extension method for the moment.
The ...
11
votes
7answers
982 views
IsNullOrWhiteSpace check for Java
I am needing to write my own IsNullOrWhiteSpace check for Java but am wondering if this is the best method to do so
...
3
votes
2answers
56 views
Slowly working word counter
I have a problem where, given N terms, the task is to find the k most frequent terms from given N terms. My code is correct, but I have a time limit 10 seconds and my code doesn't pass.
Constraints:
...
2
votes
1answer
27 views
Optimize calculation of string self-similarly with its suffixes
I am trying to solve a Hacker Rank problem about string suffixes:
For two strings A and B, we define the similarity of the strings to be
the length of the longest prefix common to both strings. ...
5
votes
1answer
50 views
Karp-Rabin string matching in Java
I wrote an implementation of the Karp-Rabin string matching algorithm in Java 7, based on the discussion in Section 32.2 of Introduction to Algorithms (CLRS). Clearly, I need more experience with ...
8
votes
3answers
305 views
The stripping extensions
In order to make my life easier with parsing some VBA code, I have written a few extension methods to extend the string type, and put them in this ...
9
votes
1answer
81 views
Counting Words in Files - MATLAB style
Note: this question may seem quite large, but the code to review is actually quite short
For my Matlab class I'm taking, I was given the task to write a function ...
6
votes
1answer
48 views
Trim Functions in COBOL
A coworker, from a past programming life, called me up last week and asked about Trim Functions in COBOL. I sent her these PEFORMed "functions", which I've had lying about and without any professional ...
4
votes
4answers
50 views
Optimise runtime of filter character method
I'm trying to run the method below against a very large corpus and I need to optimize/reduce the run time for this method as it already takes up about 6 seconds to execute.
Requirements:
Check the ...
9
votes
2answers
375 views
Replace fifth space with new line
I want to replace the fifth space in a sentence with a new line. Sample input:
"Hi this is empty string. This should be in new line!"
Expected output:
"Hi this is empty string.
This ...
8
votes
5answers
208 views
Counting the number of occurrences of chars in one string, in another string
This program counts the total number of times any character from the source string can be found in the target string.
E.g Source String - "Hello World"
Target ...
1
vote
0answers
102 views
Calculate the average length of words in a phrase [closed]
I have a function avg_word_length(str) that takes a string and calculates the average length of the words. The input has to be cleaned up before the words can be ...
2
votes
2answers
60 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
99 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
72 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:
...
4
votes
1answer
87 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
39 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
67 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
74 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
95 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
166 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
786 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
126 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 ...
7
votes
4answers
62 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
598 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
166 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
61 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
181 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
524 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
289 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
279 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
614 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
195 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
69 views
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
629 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
121 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
43 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 ...