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)

6
votes
3answers
246 views

Most Common Letter in string

Problem: Write a method that takes in a string. Your method should return the most common letter in the array, and a count of how many times it appears. Note: I solved it with Ruby, but the ...
6
votes
1answer
58 views

Splitting string by words to new strings

Function: ...
5
votes
1answer
50 views

A repeated string formatting operation

As I'm reading the Java code of some other people, I found him using an approach of assigning a format string to a variable and using the variable for String.format ...
2
votes
1answer
35 views
-4
votes
2answers
82 views

Reverse the words of a string using Java [on hold]

I wrote this program which reverses the words in a given string. Please review and give your inputs. ...
4
votes
2answers
37 views

Count chars difference between two strings

Given two strings with the same length, we check how many chars on the same positions are different. For example: ABCD and ABBD should return 1. Here is a link to a gist with tests, to have a better ...
5
votes
1answer
31 views

Finding capitalized characters and printing their position & ASCII value

I was trying to find out if a string contained a capitalized letter and if it did I wanted to know the position of the character and its ASCII code. I might have refactored a little to much. Given an ...
8
votes
3answers
134 views

Function to return last line's length of a string

I am completely re-writing the textbox GUI widget. In order to set the position cursor after the last character in the last line of a text, it is good if you know the exact column of it. So I created ...
3
votes
4answers
79 views

Are the words isomorph?

Are the words isomorphs? (Code-Golf) This is my non-golfed, readable and linear (quasi-linear?) in complexity take of the above problem. For completeness I include the description: Two words are ...
2
votes
1answer
64 views

Finding the longest repeated substring in a string

After optimising my code it still seems pretty brute force and I am looking for ideas to fundamentally improve it. I have tried improving performance by: Avoiding creating substrings as much as ...
3
votes
1answer
28 views

Date validation with html5 dates

This code validates the following: enddate should not be less than or equal to startdate. ...
6
votes
2answers
43 views

Text centering function in bash

I wanted to center some text in my commandline application, so I came up with this function. ...
4
votes
3answers
344 views

Parsing huge data coming from a URL

I need to parse the data coming from the URL which looks like this: ...
3
votes
1answer
39 views

Keeping just the rare characters in a long string

I'm working on The Python Challenge. The current code iterates over a 98,766-character string before printing an 8-character string. Current execution time is between 7 and 10 seconds. How can I ...
-3
votes
1answer
37 views

best way to determine if a string is unique in javascript [closed]

Assume there is a list of unique strings. The implementation of that list is unknown. You need to check if a given string is unique after comparing with all elements in that list, and add it to that ...
4
votes
5answers
221 views

Number of sub strings with same first and last character

Problem Statement: You are given a function \$f(x)\$, where \$f(x)\$ is \$1\$ if the first and last characters of string \$x\$ are equal; else it is \$0\$. You are given a string \$S\$ and you ...
3
votes
2answers
85 views

“The Ministry of Truth” challenge

I'm trying to solve Codeeval's The Ministry of Truth challenge, and have hit 97.5% - is anyone able to spot where my code is missing the last 2.5%? The percentage indicates that one or more of their ...
5
votes
3answers
165 views

K&R 4-12 recursive converter int to string

The exercise is: Adapt the ideas of printd to write a recursive version of itoa; that is, convert an integer into a string by calling a recursive routine. I wonder if I have correctly ...
4
votes
1answer
55 views

Creating a linked list of strings

Warning: I'm quite new to low-level programming and memory management so please don't mind it when I'm asking incredibly stupid things. I'm working on a project where I need to read all the lines ...
7
votes
1answer
93 views

Finding all possible distinct palindromes of a string

There was some online test where I was asked about finding all possible distinct palindromes of a string. Here I had to give the count of all possible distinct palindromes of a given string ...
2
votes
1answer
64 views

TDD: String Calculator Kata

String Calculator Create a simple String calculator with a method int Add(string numbers). The method can take 0, 1 or 2 numbers, and will return ...
2
votes
4answers
460 views

Add a newline to a String if not empty in Java

This should be really simple. I'm searching for the cleanest & shortest way to add a newline to a non-null String if it is not empty, i.e. myString.isEmpty() is ...
5
votes
4answers
365 views

Returning a string representation of the number of albums and songs available

What this method should do is return a String that displays how many albums and songs there are. This method is a private method ...
2
votes
1answer
51 views

Removing accents from certain characters

I have a method that I am using to remove accents from certain characters. The problem is the massive slew of characters I am expected to work with. I have to, basically, remove accents from all Latin ...
7
votes
2answers
230 views

Printing the number in large size

Problem Description Receive a 5 digit number and print out in a large size. Sample input 32145 Sample output ...
4
votes
2answers
165 views

Finding the first non-repeating character in a string

Below is a problem I encountered during an online course. There are a lot of similar questions asked on this, but I couldn't find a solution there as well as I believe my specific issue is a bit ...
7
votes
3answers
392 views

Search string for a substring - indexOf

I am trying to write my own implementation of indexOf for learning purposes. I have an implementation of as follows. I'm sure a more efficient and shorter ...
4
votes
8answers
534 views

String reversal, capitalize vowels, lowercase consonants

This was a portion of a skills test given to me by a company. The task was to write a method that takes a string, reverses it, and sets the vowels as capitals and consonants to lowercase. I was also ...
2
votes
2answers
307 views

Return the first word in the image name

I just want to return the first word in the image name (before the dash, dog in my example). Now I use it like this but believe it can be done in a simpler way ...
4
votes
1answer
53 views

Parsing a string to an object

I have this string containing this block of code: ...
5
votes
1answer
65 views

Rearranging array - with empty strings in front and non-empty strings at back

Given a string array that either contains empty strings or non-empty strings, arrange the contents such that all the empty strings are at front and non-empty strings at back, retaining their ...
7
votes
1answer
70 views

Korean Romanization to Hangeul library

After a little work, I've finally ironed this out... Though could I get someone to go over this and see if there is a better way to present this library within the code, before I publish it? Premise: ...
8
votes
2answers
136 views

Text Analyzer - Properly implementing Java coding style

As a new Java learner I would like to improve my coding style. I wrote a program which gets as an input a file name, and asks for two file names for the output. The first output file includes all the ...
4
votes
2answers
217 views

Return all words which have their reverse present in a string

Problem Statement: Given a string of words return all words which have their reverse present in the string as ( (word1 , reverseword1 ) , (word2 ,reverseword2) ) Example Case: Input: ...
2
votes
1answer
40 views

Simple string-root detection in a string-family

(this problem is related to Simple string-split by root and sufix algorithm ) There are many ways to find a "common root" of a list of similar strings, that begins with the same substring... The ...
3
votes
1answer
74 views

Simple string-split by root and sufix algorithm

A classic problem to split a string into its "root and suffix": (Stemming) The word "walk" is the base form for word "walking" (suffix is "ing"); The file path ...
3
votes
1answer
46 views

Rename subkeys of nested dictionary dynamically

My nested (ordered) dictionary looks like this: ...
3
votes
3answers
135 views

Reversing strings using recursion

I'm trying to solve exercises where I am required to use recursion. I wrote this: ...
4
votes
3answers
134 views

First non-repeated character

Challenge description is here need to find the first non repeated character from the string: Write a program which finds the first non-repeated character in a string. Input sample: The ...
4
votes
3answers
131 views

Phone List challenge

To learn Haskell, I've been going at this challenge, which is to check a list of phone numbers to ensure that no number is a prefix of another. However, my code is way too slow. I am really new to ...
4
votes
3answers
68 views

`std::vector` 'substring concatenator'

The point of this is to concatenate a vector of std::strings into one string starting at an index of the vector. ...
2
votes
3answers
63 views

Searching a string of consecutive characters in a binary bar code

I am writing a program that will take a binary bar code and convert it to a zip-code. I need to validate the bar code. A valid binary bar code contains no more and no less than two 1s in any position ...
6
votes
3answers
275 views

Article start exercise

I've used encountered this exercise from a tutorial: Create a function that takes a string as a parameter and returns True if the initial word of the string ...
3
votes
5answers
264 views

Checking if all the characters from an A-Z is present in the string

A string is said to be complete if it contains all the characters from a to z. Given a string, check if it complete or not. Input First line of the input ...
5
votes
3answers
162 views

Replacing all occurrences in a String

I have a string like this : val content = "some_text{macro1}another_text{macro2}text" I want to replace the {macro1} and ...
8
votes
3answers
448 views

Constructing a query string using StringBuilder

I speedily wrote a bunch of crappy checks, to check whether strings are empty, in order to build a query string. ...
4
votes
3answers
117 views

Build a dictionary based on split string

I've written a simple script that takes a string filled with brackets and strings and builds them to a dictionary. Example Input: ...
5
votes
1answer
82 views

Constructing Unique String Sequence

I am brushing up on my Java skills by trying to solve the below assignment problem I found on the internet: Write a Java method that accepts two strings as parameters and returns a string that ...
4
votes
1answer
53 views

Create Java object from from page content or plain text

My job is to make a specified java objects from web page that contains following text: Companies: ...