A string is a sequence of 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)

0
votes
0answers
7 views

merge and sorting arrays of String and int in more efficient methods

Are there better methods for merge and sorting arrays of int and String in more efficient methods both time-complexity wise and code-pattern wise? Also wonder if I could have a generic method that ...
1
vote
1answer
51 views

Moving files while preserving the folder structure

I'm writing a console application that will look through a directory and move any log files that have a date modified older than X days (configurable in the ...
2
votes
1answer
66 views

Checking for vowels rewrite

A few days ago I posted a little program that would check for vowels within a given word. I have rewritten this program, it can only find vowels in the English language still but, it will now tell you ...
-1
votes
2answers
63 views

Code efficiency - Piglatin

My code works and does what it is supposed to. However it needs to be more efficient. Could anyone help me tidy this up and show me where I could perhaps not rely on large loops (which it does a lot ...
6
votes
4answers
346 views

Custom user input function

The program consists of 3 files: demo.c, mylib.c and mylib.h. The code is heavily commented. ...
7
votes
5answers
1k views

Checking if a string contains vowels

I'm just learning C# and wrote a little program to check if a word contains vowels, it's fairly simple and not to exciting but I would like to know if there's ...
4
votes
1answer
49 views

Replacing multiple substrings in a string

Here are 2 functions defined that do the exactly same thing: take input a template (in which one wants to replace some substrings) and array of strings values (key value pair to replace, such as ...
3
votes
0answers
42 views

Largest common subsequence algorithm in C++

I'm relatively new to C++ and am trying to learn good programming practices and habits from the beginning. The code I wrote finds the largest common subsequence between to strings (and output the ...
2
votes
2answers
56 views

Calculating the biggest number of consecutive ones in a binary number

The following code calculates the biggest number of consecutive ones in a binary representation of a number. For example 6 -> 2 (110), 5 -> 1 (101): ...
3
votes
1answer
47 views

“Multiplying” 2 lists of Strings together in Java 8

The following method is part of a class that imports zip archives, and part of that class's job is to verify that a given zip archive contains "complete filesets". A "complete fileset" is one such ...
5
votes
3answers
439 views

The Genetic Code

This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Wascally wabbits. The repository with all my up-to-date solutions so far can be found ...
4
votes
2answers
69 views

Recreating strstr in C

I'm trying to recreate strstr in c, my code works but I think it is too long, and it needs some improvement. ...
3
votes
2answers
54 views

Simple 'Evolution of Text' app

I'm a complete beginner to Python, and wanted to get some feedback on my first app. I tried to make a clone of the 'evolution of text' app found on the Using Python website. Enter some text, and ...
6
votes
3answers
692 views

Printing alternating characters of a string using Java 8 streams

Given a string, S, of length N that is indexed from 0 to N−1, I want to print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line: Hacker -> Hce akr My code ...
1
vote
2answers
34 views

SPOJ “TESSER” - Getting TLE using KMP algorithm

The TESSER - Finding the Tesserect problem is tagged as a problem to be solved by Knuth-Morris-Pratt (KMP) algorithm. I'm using KMP, but am still getting time-limit-exceeded. Task Each of T test ...
4
votes
2answers
83 views

Let me fix thou number

Problem Statement: Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is less than 10 ...
1
vote
1answer
40 views

Concat strings from Object or Array

How would you merge these two functions into a single more generic function? ...
15
votes
5answers
1k views

Generating Robot Name

Problem: Write a program that manages robot factory settings. When robots come off the factory floor, they have no name. The first time you boot them up, a random name is generated, such ...
2
votes
1answer
55 views

Swift solution to Leetcode “Longest Substring Without Repeating Characters”

From LeetCode medium 3. Longest Substring Without Repeating Characters: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", ...
18
votes
3answers
3k views

What does the Bob say?

Description: Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a question. He answers 'Whoa, chill out!' if you yell ...
3
votes
2answers
83 views

Parsing a string with named sections and a key-value pair on each line

I have a response String as shown below which I need to parse it and store it my class. Format is shown below: task name followed by this dotted line ...
1
vote
0answers
16 views

Password Entropy in Lazarus (Delphi-like)

My today's goal was to create a function, which would evaluate the entropy of a given string password. It's mostly about how random the password is. This little code is based on the C# code from Jeff ...
4
votes
1answer
56 views

Alternate letters to UpperCase

As an exercise I repeated this Java question, but in Go: Convert string to mixed case The objective is for every second letter to be converted to uppercase. Go string processing is relatively new to ...
2
votes
3answers
148 views

Convert string to mixed case

This method converts a string to mixed case, id est mixedCase("hello, world!") -> "HeLlO, wOrLd!". ...
4
votes
2answers
45 views

Counting from 0 to a number and back to zero, and space-padding the result to be a given length

I completed a task: The objective was to create a method with 2 arguments: a number to count to, and how many char/numbers in the resulting string. Result: Let's say that "number" is 5, so it will ...
-1
votes
2answers
38 views

Find multiple keyphrases from a text

I have keyphrases abc, xyz, pqr, mno, etc. Text - " this text contains abc and mno", want to find whether text contains keyphrase string. I am looking for an efficient solution. ...
1
vote
2answers
52 views

Finding palindromes and the longest word in a string

I have two little projects that I've been working on. One is to find all palindromes: ...
5
votes
1answer
51 views

Lazy String splitter in C++

I created a string splitter in C++. It splits a string in a lazy fashion and makes use of forward iterators to sequentially supply the next token from the string until it runs out of tokens. ...
1
vote
1answer
38 views

Alternative to using strncpy() as 'safe' version of strcpy()

I am thinking of using this as part of a header file to give me a useful string-manipulation tool. Elements is size of dest to prevent overflow: ...
4
votes
4answers
292 views

Removing duplicate characters from a string

I implemented a function removeDuplicates which takes 1 parameter, a std::string, and returns a ...
0
votes
2answers
74 views

Student class with std::string

I am writing a class that has a few std::string as a member. I can't find clear guidelines on how use them in a safe way. Are ...
3
votes
1answer
55 views

Determining if a string is a palindrome of a permutation

I wrote code to determine if a string is a palindrome of a permutation. This exercise was taken from Cracking the Coding Interview. I'm looking for any tips on improving it. ...
0
votes
4answers
122 views

Remove “b” and “ac” from a given string

I coded this solution for this problem: Given a string, eliminate all “b” and “ac” in the string, you have to replace them in-place, and you are only allowed to iterate over the string once Seems to ...
17
votes
5answers
2k views

Word Inverter in C

I've just made this program and I want to know how to improve it. It just receives a word and prints it backwards. Sequences of numbers are also accepted, but not white spaces (that's why I used ...
5
votes
2answers
101 views

x86 assembly method that mimics strcat

I'm trying to learn x86 assembly and hopefully move on to projects of the scope that more than one person would be involved. This is a (relatively) simple subroutine written in Intel x86 assembly ...
5
votes
1answer
66 views

run command pipeline in C

This code parses and tokenizes my shell language command interpreter. I will try and make it 2 functions, one that is the tokenizer and the other that is the rest of the function. Can you find ...
-1
votes
1answer
55 views

Determining whether a string can be rearranged into a palindrome

For a string, count the number of occurences of each character. If at most one character has odd count then the string can be a palindrome else it's not. ...
2
votes
1answer
62 views

Parsing in between of brackets

I do parsing of the string in order to find wrapped sub-string inside brackets of the first level. a+(b+(d-g))+g+d, in this case I will need to separate ...
4
votes
2answers
128 views

My implementation of String in C++

I wrote my string class. The code works, but could anyone tell if I am doing anything wrong? It is an exercise from the "Accelerated c++" book: Implement the Str class, but choose an ...
1
vote
1answer
57 views

Levenshtein distance with edit sequence and alignment in Java

I have this program that computes a Levenshtein distance of the two input strings, their edit sequence, and the alignment: LevenshteinEditDistance.java: ...
2
votes
2answers
58 views

JavaScript function to convert underscore-case to camel-case (and vice-versa)

Actually I needed a function which converts underscore to camel-case. But then I've had the idea: Why not extend the function so, that is works the other way around? Finally I recalled that there is ...
3
votes
1answer
41 views

Anagram counter

Homework prompt was: You are given two strings, a ‘parent’ string and a ‘query’ string respectively. Your task is to determine how many times the query string – or an anagram of the query string ...
5
votes
1answer
81 views

An extension to the StringBuilder

This is another pretty basic class I wrote for a library as I hate the way the default StringBuilder in .NET works. Essentially, I wanted to have the ...
1
vote
0answers
31 views

Given an array of strings, group the anagrams together

Scan the array of strings, for each string get the code(which is nothing but the summation of char values of the string) and add the string to TreeSet<String> ...
4
votes
1answer
98 views

Finding number of times each string in an Array of strings occurs in a large stream of characters (i.e large string)

Interview problem: Given a stream of characters (e.g. acacabcatghhellomvnsdb) and a list of words (e.g. ["aca","cat","hello","world"] ) find and display count of each and every word once the ...
1
vote
1answer
36 views

Given an array of Strings , check if they are anagrams are not

Two strings are anagrams if they are permutations of each other. Assuming we have an ASCII alphabet we can take 128 integer array to count the characters in the first string. Then decrement the count ...
3
votes
1answer
26 views

String Matching w/o repeating the comparisons for common part of the two strings

In an attempt to think up a more efficient String Matching algorithm than the naïve \$O(n \cdot k)\$ one I came up with a slightly modified approach. In my algorithm (code in Java), I tried a little ...
2
votes
1answer
59 views

String-casting utility functions

I wrote a small header that is supposed to take care of calling the right strtoX or or stoX function for me and doing so at ...
3
votes
2answers
64 views

Simple function to generate an HTML-safe string

Sometimes, we have to do some fixing to insert a string into an HTML property. Or just to display it. But not everything is safe! Consider the following example: ...