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)

5
votes
3answers
355 views

Interview solutions to reverse a string and reverse a sentence

Recently in an interview I was asked to Write a method to reverse a string. I used StringBuilder but was asked not to use reverse method of builder but iterate ...
2
votes
1answer
27 views

Processing a string containing product variants

I have a variable containing a string in this format "Size-XS|Size-XL|Color-Red|Color-Green". When i process it the final result is "Variations: Size: XS, XL, Color: Green, Red. The code for this is ...
4
votes
1answer
32 views

Finding longest common prefix

I have been trying to solve a modification of the Longest Common Prefix problem. It is defined below. Defining substring For a string P with characters P1, P2,…, Pq, let us denote by P[i, j] ...
1
vote
1answer
109 views

Function to find a substring within a string [on hold]

I've just completed an exercise in which I had to create a program that searches for a string within another bigger string. If the substring exists then it is outputted to confirm and the starting ...
0
votes
0answers
17 views

Concatenating an array of optional NSAttributedStrings

Imagine you had to join together attributed strings with a separator in between them. Which of the following methods would you use? An extension on SequenceType with a function that takes in a ...
9
votes
2answers
421 views

Break a full name into a dictionary of its parts

It seems like I'm repeating myself here. Is there a standard way to deal with code like this? ...
3
votes
2answers
916 views

Morse Code Conversion

Challenge Write a program which reads a file containing Morse Code and outputs the conversion. Specifications The first argument is a path to a file. The file contains multiple lines. Each line ...
2
votes
1answer
64 views

Concatenating two substrings to provide the largest possible palindromic string

The code extracts two substrings from different strings and concatinating them to provide the largest possible palindromic string. Objective: You have two strings, (a) and (b). Find a string, (c),...
8
votes
2answers
167 views

Displaying all substrings of some given string

I solved exercise 8 from Core Java for Impatient, chapter 1. This exercise is to implement a displayAllCombinations method to display all substrings of the given ...
3
votes
2answers
35 views

Getting the smallest snippet from content containing all keywords

This returns the smallest snippet from the content containing all of the given keywords (in any order). This provides the correct solution but I would like to know if it can be made more efficient. <...
-1
votes
0answers
25 views

Random password generator for my iOS app using Objective-C [closed]

I am trying to make a random password generator for my ios app using Objective-C and I was wondering if i was doing it correctly. I want to run this in Xcode. ...
1
vote
1answer
52 views

Java password encryption based on time and string

I have a program that: Takes a user specified string Creates password from the string and previous, current, and next day Encrypts the strings Chops some middle characters from the strings (needed ...
8
votes
3answers
878 views

Word-counting script in C#

My goal is to read from standard input, break up the input into words (Unicode letters and apostrophes), case-insensitively, and produce a report to standard output, where each line is a word followed ...
3
votes
1answer
29 views

Matlab implementation of Needleman-Wunsch algorithm

This code (an implementation of the path finding Needleman-Wunsch algorithm), given two sequences, correctly aligns and calculates the similarity of them. For example, given two sequences: AAA,CCC ...
9
votes
2answers
223 views

Converting Morse Code

Challenge Write a program which reads a file containing Morse Code and outputs the conversion. Specifications The first argument is a path to a file. The file contains multiple lines. Each line ...
1
vote
1answer
63 views

Check if vector of strings has matching brackets

For an online screen, I had a question that would take in a vector of strings, and return a vector of strings indicating whether the input string was a valid combination of ...
4
votes
3answers
90 views

Program to reverse a string using std::string

Background: I'm trying to learn C++ and I'm doing that by writing some programs by myself. I'm decent with C, but I'm having trouble translating to OOP paradigm. I'm reading from learncpp.com and a ...
4
votes
0answers
27 views

Princeton KMP implementation

I implemented a Python version of KMP followed by Princeton Prof Robert Sedgewick's discussion. However, I got a Time Limit Exceeds error. Per leetcode's explanation, TLE indicates that the solution ...
3
votes
2answers
70 views

Finding the index of the character whose removal will make a palindrome

Before I get into describing by problem I'd like to point out I found this question under c++ tag. But the solution of that question is already implemented in my ...
5
votes
2answers
45 views

Analyze huge set of sentences for word presence

I have a huge file (1Gb) with English sentences and I need to filter only those containing the Alice word. Actual tests could be more complex, e.g. matching a verb by its wordforms (go, goes, gone, ...
51
votes
1answer
4k views

NUMAH LITTERS OV KITTEHS ON TEH NETZ

It's not fair that 1% of the users hold 75% of the lolcode questions. #OccupyMatsMug ~ user2296177 I agree. Without further ado, here's the LOLCODE version of 99 bottles of beer on the wall: <...
0
votes
1answer
31 views

Code to join filesystem path strings in PHP

Following code has some issues: ...
2
votes
2answers
82 views

Implementing a Sort for an Array

Yesterday, I gave an interview after a long time, and I was asked a question which I couldn't solve on the spot. I had to implement a sort function for a Array of strings in JavaScript, with the ...
4
votes
1answer
197 views

Checking if two strings are anagrams

Here is my code for checking to see if two strings are anagrams. This seems a little short. Am I missing anything? Both time and space complexity seem to be \$O(1)\$. ...
1
vote
1answer
36 views

Log collisions in generating unique random strings

I've created a small class to generate unique random strings. It works fine. I also want to log the collisions of the generated strings. I check if the generated string is in the array for uniquness: ...
3
votes
2answers
88 views

'Broken Record' Coding Challenge

I was asked to complete a coding challenge for an interview. The challenge being to write a test function to check whether or not a string was a broken record. A <...
7
votes
3answers
368 views

Converting string to control

This is my first post here. I had a look for my question, but nothing quite answered what I'm looking for. I've just started learning C#. I have an up-down numeric control on my form (...
28
votes
8answers
6k views

C program that reverses a string

As practice with the (ever so painful) C Strings I wrote a string reversal program. I am new to C, so I wanted to make sure that I am not using bad coding practices. It runs just fine (at least with ...
0
votes
2answers
77 views

Checking if a string has all unique characters

I'm wondering if this code can be optimized in terms of time complexity. The problem is checking to see if a string has all unique characters. ...
0
votes
0answers
34 views

Suffix tree code

I am always having confusion when it comes to run time complexity of an algorithm. I wrote this code for suffix array, I am not sure of the run time complexity of ...
6
votes
4answers
953 views

Implement an algorithm to determine if a string has all unique characters

I'm working through Cracking the Coding Interview. The first challenge is to implement an algorithm to determine if a string has all unique characters. I've gone through several iterations, but here'...
0
votes
1answer
64 views

Removing a specific character and its neighbors from a string

Assume we have an string that contains the character 'c'. This character can be located anywhere within the string. The exercise ...
1
vote
1answer
44 views
3
votes
1answer
48 views

Count character replacements needed to make string a palindrome

Problem Count the number of character replacements necessary to convert an input String to a palindrome. Each character replacement must replace the given ...
6
votes
2answers
78 views

Find the longest string without repeating a letter

I've written some code to scan large files and search for long strings that you can write without repeating a letter. I'm self-taught in python and I'm wondering what I've missed. ...
0
votes
2answers
69 views
5
votes
1answer
134 views

Broken keyboard challenge

Inspired by Reddit r/dailyprogrammer Help! My keyboard is broken, only a few keys work any more. If I tell you what keys work, can you tell me what words I can write? The program works fine, ...
1
vote
1answer
42 views

Printing the power set of a given set of elements

Input: Set of elements (String) Output: Printing the elements of the power set of the given set ...
2
votes
2answers
110 views

Reverse string in JavaScript without using reverse()

I have to reverse a string in JavaScript and cannot use the built in reverse() function. It does not seem efficient to have to create two arrays but is there a ...
1
vote
2answers
51 views

Finding a word with the most occurrences of a character

I am new to PHP development. So Kindly, review my code and guide me make it better/optimize. Currently, it works well with inputs that I have tried. ...
3
votes
4answers
122 views

Remove adjacent duplicate characters

Introduction This problem is essentially equivalent to this HackerRank problem. The task is to remove all duplicate characters that are adjacent to each other in a given ...
3
votes
1answer
41 views

Read file contents to string safely

I've just started to teach myself Rust. I've written the following code to read a text file and store the contents in a String. Is this the typical way of doing ...
7
votes
1answer
138 views

Extension method splitting string on each capital letter

I'm creating my own game and for some statistics I need to get the names of specific objects. The problem was that I had them declared like "SmallFireBall" but I wanted them to appear like"Small Fire ...
5
votes
1answer
74 views

Reversing a word or sentence

Was just wanting some general feedback on the below code regarding 1. Readability 2. Structure 3. Efficiency ...
4
votes
2answers
149 views

A String.prototype.diff() implementation (text diff)

I just had the idea to develop an algorithm to calculate and highlight the difference between two strings. I know that there are already some libraries to do the job but i just tried to make my own. I ...
5
votes
1answer
48 views

Python comparing a string or list of strings to a string or list

I'm using a selfmade python program for learning new words in new languages. Originally I made this program for a university course but now I'm just trying to imrove it and make the code "prettier" ...
2
votes
3answers
115 views

Split string into 160-character chunks while adding text to each part

The send_sms_message method takes text as an argument. The length of text is unknown and can ...
12
votes
6answers
2k views

Find the first non-repeating character in a string: (“DEFD” → E)

I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Find the first non-repeating character in a string: ("DEFD" --> E) I didn't pass the coding ...
3
votes
1answer
54 views

Implementing joinWithSeparator on a Character array

I recently answered a Stack Overflow question about transforming an array of Characters into a String in Swift. Looking at the question and the Swift standard lib, it appears that there is a method <...
7
votes
2answers
339 views

Validate whether a ransom note can be made from a dictionary of words

For simplicity, it is checking whether the characters in a string (that needs to be created) are present in a larger string (dictionary). Would a character array of the letters make sense here, or ...