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
2answers
261 views

Reduce as many adjacent chars as possible in string

This code is meant to reduce a given string as much as possible by deleting adjacent characters. Here are some examples: ...
5
votes
1answer
59 views

Text search in Python

Whilst self-studying algorithms, I came across the Karp-Rabin rolling hash search algorithm here. I decided to have a go at implementing it in Python: For ease of reading; the data-structure ...
5
votes
1answer
286 views

Find all strings in list which have keywords in it from another list

I a list of strings A and a list of keywords B. Now I want to return all strings from list A which have all keywords from B in it as a new list. ...
3
votes
3answers
63 views

Reverse vowels in a string

What do you think about this solution? I guess there are too many lists... ...
3
votes
4answers
61 views

Program to rotate an array

I wrote this code where I have to rotate an array of 'n' elements by 'd' elements in the anti-clockwise direction.Can it be done in a better and simpler way? ...
1
vote
3answers
51 views

C strlcat implementation

I have to reproduce some basic functions in C and one of them is strlcat. After reading the man and testing the strlcat from <bsd/string.h> library, I wrote ...
3
votes
1answer
48 views

Win32/C: Notepad wrapper that automatically converts Unix line endings to Windows line endings

At my work we're dealing with a lot of PHP files written by a third-party company and sometimes we want to "quickly look at" these files in Notepad rather than having to open up a full IDE. The ...
4
votes
1answer
38 views

Interleaving of two strings

I have written this recursive code to find all interleaves of two strings, where the order of strings are preserved. For example: s1="abc" s2="1" a1bc ab1c abc1 ...
-2
votes
0answers
18 views

How can I find the longest repeating(consecutive) substring in a string? [closed]

The following is my code. I have some testcases and some of them are wrong. In this problem, I should not use suffix tree. All I need is modify or add something to my code so java runs correctly. (...
1
vote
1answer
53 views

Program for an atoi() function in Java

I have written this code to check all the edge cases in the implemention of an atoi() function.Please review. ...
3
votes
1answer
51 views

Concatenate variable number of strings

I am learning C on my own. This is not an assignment. I am trying to implement a function that takes a variable numbers of strings and concatenate them in a new string. It works, but I feel it is not ...
4
votes
1answer
28 views

String tokenizing with arbitrary token count in C

I am building a small program for input handling so I can conveniently parse lines and tokenize strings. The token handling works right now but I have to malloc a lot in the main() to make it work. ...
6
votes
2answers
277 views

Function to find all occurrences of substring

This function returns a list of all the beginning indices of a substring in a string. After finding the index of a substring, the search for the next one begins just after this index. ...
1
vote
2answers
25 views

Title capitalization exercise from The Odin Project

I just finished the book title class exercise for The Odin Project and I would appreciate some honest feedback for my code. The code is intended to be "test-driven learning", and therefore emulates ...
3
votes
2answers
404 views

Python-style string multiplication

When people migrate from Python to C++, they're often bothered by the fact that C++ strings don't support multiplication like Python's strings do. std::string does ...
5
votes
2answers
75 views

Simple Java password rule enforcing

rule 1: length must be between 8 and 50 chars. rule 2: at least 3 of the 4 following rules: --------2a: at least one upper case --------2b: at least one lower case --------2c: at least one numeral ----...
3
votes
2answers
54 views

Removing extra spaces without using a regular expression

I want to remove the extra spaces without using a regular expression. I'm using two while loops. How can this become better / more elegant? ...
6
votes
1answer
48 views

Zalera calculator

I recently started replaying Final Fantasy XII. One of it's optional bosses, Zalera, has, among others, the following mechanics: His attack sequence is Lv. 2 Sleep, Lv. 3 Disable, Lv. 4 Break and ...
3
votes
4answers
628 views

Program to check whether two strings are anagrams of each other

I have written this code and I am wondering if the code could be optimised.Please review. ...
3
votes
2answers
50 views

Building a summary string from a flags enum

I'm trying to replicate the attributes text that appears in File Explorer, for files and directories. I can't just use the enum names, as the summary text uses a single character for each set flag, ...
2
votes
1answer
68 views

Producing residues of combinatorics on strings

Basically, this code does multiplication of chosen operations. ...
6
votes
3answers
104 views

Interpreter programming challenge

I have posted here my working and accepted solution to the intepreter programming challenge (detailed here) for your review. The challenge is as follows: A certain computer has 10 registers and ...
3
votes
2answers
84 views

Delimited File Reader

UPDATE: I have refactored the code into a Gist using @Dmitry's answer as a guide. The update is much simpler to grok, implements IDisposable, and is roughly thirty ...
6
votes
1answer
149 views

How random can you get?

I work for a service desk and change A LOT of passwords. Most the time the end user is a complete fool that doesn't understand the requirements for the password they want to use. So I created a ...
2
votes
2answers
50 views

Finding a common prefix/suffix in a list/tuple of strings

The question that sparked this question, was one on Stack Overflow in which the OP was looking for a way to find a common prefix among file names( a list of strings). While an answer was given that ...
1
vote
1answer
61 views

Longest common substring using dynamic programming

I've written a short python script that attempts to solve the problem of finding the longest common substring using the dynamic programming technique. It is meant to be generalised so I could plug in ...
1
vote
0answers
40 views

Extracting names from a body of text

I am trying to extract names from a body of text to use as stopwords. I tried a few different approaches to identifying names (or proper nouns in general) below. The second approach is much faster ...
3
votes
0answers
22 views

Converting a sentence string to a number in Scheme

I wrote a scheme procedure that converts strings such as "Two hundred and fifty" into a number like "250" that I can use in math calculations (It's for some Natural Language Processing project). Is ...
3
votes
1answer
87 views

Detect if string contains more than 1 period

This function returns true if the string contains zero or one periods, and returns false if the string contains more than one ...
1
vote
1answer
69 views

Check if strings are substrings of another string in Python

My problem starts with a list A (length around n = 100) of big strings (around 10000 characters each). I also have another q = 10000 strings of length 100. I want to check if each string is a ...
3
votes
2answers
138 views

Using C++ to check if string s is subsequence of string t

The problem I want to solve is very simple: Given a string s and a string t, check if s is subsequence of t. there is only lower case English letters in both s and t. t is potentially a very long (...
8
votes
3answers
240 views

Removing multiple slashes from path

I have been trying to write a sample code block to remove multiple backward or forward slashes from a path (e.g. //a//b should be ...
2
votes
2answers
69 views

X86_64 implementation of STRCHR using NASM

As this will eventually become part of an operating system I'm developing, there is no specific adherence to any particular ABI, even though this is being developed ...
0
votes
2answers
60 views

Find first non-repetitive character in a string

The original task was to find the first non-repetitive character in a string. Every now and then I read questions here on Code Review and try answering them myself, and as such I stumbled upon this ...
2
votes
0answers
34 views

Negation detection in sentiment analysis

This basic function to detect negation while performing sentiment analysis. So that not good kind of words can be considered a negative. This code is working fine. ...
9
votes
5answers
957 views

Find first non-repetitive char in a string

I just had an interview for the C#.NET developer position and I was asked to find the first non repetitive char in a given string without using any library functions but just the basic constructs of ...
0
votes
2answers
84 views

Most common letter in string, trying to use idiomatic Ruby

The task: 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. Model solution: ...
3
votes
1answer
60 views

Outputting years with no repeated digits

I'm working through a course now, and was tasked with the following: Write a function, no_repeats(year_start, year_end), which takes a range of years and outputs ...
4
votes
2answers
306 views

string.find versus this function

I got bored and decided to write my own function to verify if a string contains another string. I was wondering if there's any major difference between these two function except the one I wrote being ...
0
votes
0answers
13 views

(follow up) StringRef v.2 - read only std::string like class similar to boost::string_ref and std::string_view

Idea behind the class is same as C++17 std::string_view, boost::string_ref or llvm::SrtingRef...
4
votes
2answers
759 views

Checking the balanced parenthesis as asked in interview

Input: Input contains one string S which consists of big and small latin letters, digits, punctuation marks and brackets from the set []{}(). Constraint: Constraints. The length of S ...
1
vote
2answers
103 views

Given two strings, a and b, determine the minimum number of character deletions required to make a and b anagrams

I'm trying to figure out how my code could be improved. I solved a HackerRank problem from the Cracking the Coding Interview section, and am thinking that it should be able to be solved a simpler than ...
1
vote
2answers
152 views

Swap first and last name in C

I took an entire line of input in the form of a string, and tokenized the string into substrings and obtained the first string as the first name and the second as the last name. This program as it ...
5
votes
4answers
313 views

Find the shortest whole repetitive substring

I'm working on a problem to find wholly repeated shortest substring of a given string, and if no match, return length of the string. My major idea is using a Trie ...
3
votes
1answer
56 views

Printing different aspects of a binary tree

I had an assignment, for which I got full marks, but am really upset about the code I have written. I feel it is too manual and repetitive. Please help me make it more optimized. I am making many ...
4
votes
2answers
39 views

Parse a substring out of string, allocate memory accordingly

I have written the following code in order to: Find begin and end of FTP user and password from a given URL (ftp://[user[:password]@]host[:port]/url-path) Allocate ...
1
vote
2answers
72 views

Finding the longest palindrome from the given string

Recently I came across this problem which instructs me to find the longest substring which is a palindrome: As we all know, a palindrome is a word that equals its reverse. Here are some examples ...
1
vote
2answers
94 views
6
votes
2answers
115 views

Performing a procedure for each form edit

I am a bit new to programming. I have some edits on my form, and for each edit completed it will have to do a procedure. Currently, I use this code that works perfectly, but I am looking for a better ...