Questions tagged [strings]

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.

Filter by
Sorted by
Tagged with
1
vote
1answer
37 views

Rust - insert into piecetable

I'm writing a piece table library in Rust with the structures: #[derive(Default)] struct Piece { additional: bool, offset: usize, length: usize, } and <...
6
votes
1answer
339 views

Capitalizing the first letter of every word in a string (with arbitrary spacing)

I solved the following question You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised ...
4
votes
2answers
81 views

Converting a string into an array and returning the values spelled in reverse

I must create a function that accepts a string of names all separated by a comma. Example: "Jack,Matthew,John,Sam" And return the string of names in the ...
18
votes
4answers
2k views

Add 'ing' or 'ly' suffix to a string

I have been practising Python Practice questions and came across this question: Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string ...
6
votes
0answers
81 views

Generate unique random strings considering collisions

I'm coding a random strings generator. It's working, but I'm not sure if this is efficient. ...
5
votes
2answers
70 views

Log file name adjustment

I have the following code that takes user input "path" and adds the current time into the filename after the name part and before any extension (if it exists). It seems a little hacky to me ...
4
votes
1answer
134 views

Finding Pattern Score in Python

I saw this problem in C++ on here and decided to try it in Python, which was much simpler. I've used the same problem blurb as in the link above, so they are consistent. I'm sure my code can be ...
3
votes
3answers
56 views

Concatenating optional strings in Scala

I have two optional strings, any of them can be None. I want to create their combination with a delimiter between them if they both exist. I expect to be able to come with a more concise and nicer ...
1
vote
2answers
85 views

Sorting string with if-else

I was asked to write a program that sorts three strings alphabetically using only if-else (no sorting algorithms, usage of arrays whatsover). I'm fairly new to C++ programming but I've come up with ...
5
votes
1answer
76 views

LeetCode 1638: Count Substrings That Differ by One Character

I'm posting a solution for LeetCode's "Count Substrings That Differ by One Character". If you'd like to review, please do. Thank you! Problem Given two strings s and t, find the number of ...
5
votes
4answers
129 views

String concatenation challange to be more efficient with DayOfWeek and Lists

I have this challange that I finished which asked to print out a string according to the provided schedule. Here is an example: ...
0
votes
1answer
69 views

Generate unique string permutations recursively

🧩 Objective Write a recursive method for generating all permutations of an input string. Return them as a set. See: Recursive String Permutations - Interview Cake 🔎 Questions 1: How does the ...
6
votes
2answers
215 views

String/text manipulation utility class

I'd like to get some expert's view on this first piece of code especially in the area of performance - (e.g. avoidable copies) good practice (e.g. static members?) The final goal is the provide some ...
4
votes
3answers
178 views

Microsoft OA | Longest Substring Without 3 Contiguous Occurrences of Letter

For the following question, does my JS Solution seem correct? I'm looking for some peer review. Q: Given a string s containing only a and b, find longest substring of s such that s does not contain ...
9
votes
1answer
151 views

LeetCode on Longest Palindromic Substring in Python

This is a programming question from LeetCode: Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is ...
8
votes
3answers
278 views

Creating Two-Dimensional String Array for Plane Seats

I'm creating a ticket reservation system in Java, I want to use a Two-dimensional String array for managing the seats. I have enums that hold the plane model and the amount of seats available so the ...
7
votes
2answers
523 views

Number of occurrences of strings in array

This is a Hackerrank problem (https://www.hackerrank.com/challenges/sparse-arrays/problem). We're given an array of strings and an array of queries, and have to return an array of the number of ...
4
votes
1answer
69 views

Processing delimiter characters in C?

Write a C program that will implement the basic operations of table processors. The input will be text data read from a .txt file, operations will be defined using terminal arguments, and the output ...
4
votes
4answers
243 views

Convert Integer to Binary String

This code takes a user input number which is a positive integer, and outputs a string representation of the number in binary. For example, input 2 outputs ...
12
votes
3answers
1k views

Split string algorithm

I just wanted to get ideas on how to improve my algorithm, the requirements are as follows: You are given a string S consisting of letters 'a' and 'b'. You want to split it into three separate non-...
4
votes
1answer
222 views

Get parent path

I am trying to write a function that would do what a cd .. would do. Basically get the parent of the given path. eg: ...
7
votes
4answers
1k views

How can I efficiently manipulate digits in a string without using RegEx in Java?

I am reading a book with different quizzes about coding interviews. Please implement a function that increments a string based on the rules below: It should take the string of unknown length and ...
6
votes
4answers
906 views

First non repeated character

Problem Statement : Print the first non repeating character in a string. Example : In the string somecharsjustdon'tliketorepeat, ...
3
votes
3answers
75 views

Initializing an array of string constants, and another constant array of the equivalent lengths

Ok, a struct would actually be most convenient, but it woudl be easier on teh system to have 2 seperate arrays rather than an array of structs. ...
2
votes
2answers
81 views

String Mutator performance

I've made a very basic wrapper over a String that offers mutability in place (context: mono/XNA, budget is about 11ms per frame, 0B (ZERO, NIL, НОЛЬ, NADA) allocations hard requirement). Before that I'...
9
votes
4answers
839 views

StringTokenizer for .NET Core

Splitting a string in tokens is a more complex topic than String.Split() wants to make us believe. There are at least three common policies according to which a string might be interpreted and split ...
2
votes
1answer
55 views

Converting an integer to a hexadecimal string representation in Java

I have rolled my own Java method for converting ints to the hexadecimal Strings: ...
6
votes
2answers
103 views

Hide certain email characters

Hide email characters: When email only has one letter then just cover that letter with the * symbol e.g. *@gmail.com When ...
4
votes
3answers
456 views

String class implementation

I'm working on a project (it's a language), and for that project, I decided to go with a low-level C++ style, so that means making my own data types. I recently got done making my own string class ...
3
votes
0answers
63 views

Early Stages of floating point class template in C++

I'm currently designing a class template to represent scientific notation or a floating-point number system. There are currently 4 distinct types: BIN, ...
5
votes
4answers
193 views

C#: Repeated String

From HackerRank "Repeated String" challenge: Lilah has a string, \$s\$, of lowercase English letters that she repeated infinitely many times. Given an integer, \$n\$, find and print the ...
5
votes
1answer
91 views

Similarity between words

I'm writing a method that writes the code for a loading routine. Given an object from the database, I want to put its properties in the right control on a userform. I have the list of the properties ...
6
votes
2answers
80 views

My first C# project - Simple bird of prey identification console app. Does it need refactoring or complete rewriting?

this was my first thing i made on my own without any help. im sure theres a lot of improvement that could be made, i dont feel too confident about this. how can i make it shorter and more efficient? ...
4
votes
1answer
87 views

LeetCode: Find And Replace in String C#

It took me a while to solve this question and there are corner cases i missed hence the 4 unit tests. please review for performance. and if you can treat this as a review for a 45 mins programming ...
1
vote
0answers
33 views

Custom include? method for a substring

Task: Write a function which returns true if a given substring is found within a given string. If the substring isn't found, then return false. My implementation: ...
6
votes
1answer
80 views

Reverse character order of substrings delineated by white space chars

The Challenge: Given a string, return a string where each word is reversed individually without changing its position. EDIT: (i.e.: the input "hello world I am a frog?" should produce the ...
2
votes
1answer
72 views

Add comma/and between string array in java

i get an array of authors from json response and i have to display authors name in TextView(android) in proper format like =>Viraj, Chetan and George R. R. Martin my code work fine, but it's a mess....
7
votes
1answer
276 views

JavaScript string to Unicode (Hex)

This set of questions are related to a project I've published for converting characters, or strings, to Hex based Unicode; eg... ...
6
votes
2answers
173 views

Python - use a list of names to find exact match in pandas column containing emails

I have an Excel file containing a free-form text column (that sometimes is structured like an email), where I need to find all first and last names and add an extra columns saying TRUE/FALSE to these ...
1
vote
1answer
86 views

Getting 6000+ substrings from large a large string

I have a class that opens a text file and reads out its content. This class has a member function that will extract a substring between two given delimiters. My application needs to extract between ...
3
votes
2answers
116 views

Random alphanumeric string generator function (C, Windows, bcrypt.h)

The function uses the Windows "Cryptography API: Next Generation" (bcrypt.h)'s BCryptGenRandom function to generate ...
4
votes
2answers
167 views

Checking if a string contains all unique characters

I am currently reviewing CTCI(Cracking the Coding Interview) The question is asking me to implement an algorithm which checks whether the characters in a string are all unique however they do not want ...
4
votes
2answers
56 views

Format string processing similar to date or printf()

I wrote a function that is supposed to take a format string similar to what date accepts and replace all format specifiers with strings provided by a callback ...
-3
votes
1answer
39 views

I am trying to save a string to a MYSQL table from a radiobutton in java/Android studio [closed]

I am trying to save a radiobutton string if it clicked. I am making a survey where I need to save a "yes" or "no" into a MYSQL table using volley. I am having a little trouble ...
12
votes
2answers
471 views

C# - name separation & last name in upper to Camel

I had an xls file with lots of full names in the following form at work: ...
3
votes
1answer
76 views

Simple Password Generator Feedback

This is my first major project in F#, looking for any critique on how I can make it more standard or more concise. Some things I feel like I could have done better are the command flag parsing and the ...
3
votes
3answers
113 views

Optimize Memory Java String Array

I was trying to solve one programming challenge : First input is a list of connections which is made of pair of IPv4 address. Each IP has its own state which starts with false, each connection also ...
1
vote
1answer
87 views

Filtering a Vec of structs and creating new vector of Strings or strs in Rust

I'm working through the Rust book, and it has the following example of how to use the filter method on Iterators (source): ...
2
votes
2answers
106 views

Exercism: determine if a word or phrase is an isogram

The task: Determine if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed ...
3
votes
2answers
83 views

Code to modify string as per instructions

I solved this problem statement on dear old codeforces. The Problem Statement wants users to replace occurrences of '10' in the given string with either '1' or '0' until there is no occurrence of '10' ...

1
2 3 4 5
53