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
-4
votes
1answer
33 views

What does %s mean in a python strings? [closed]

I'm not sure what %s means in Python strings. I came across this line of code somewhere a while ago: ...
6
votes
1answer
272 views

K&R Exercise 1-21. Write a program `entab` that replaces strings of blanks with tabs

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
1
vote
1answer
42 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 <...
4
votes
2answers
87 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 ...
6
votes
1answer
343 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 ...
9
votes
4answers
2k views

String Operation to Split on Punctuation

I've a function to split text on punctuation and leave the rest of the string (including whitespace in other items of the list): ...
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
84 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
5answers
936 views

Convert Integer to String without using Java API library

I have written a Java program that converts an integer to String digit by digit and concatenate them together using the + operator without touching the Stock Java API library. I like to have feedback ...
3
votes
3answers
57 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 ...
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 ...
15
votes
3answers
26k views

Count byte length of string

I am looking for some guidance and optimization pointers for my custom JavaScript function which counts the bytes in a string rather than just chars. The website uses UTF-8 and I am looking to ...
4
votes
1answer
136 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 ...
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 ...
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: ...
5
votes
1answer
78 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 ...
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 ...
4
votes
3answers
180 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 ...
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 ...
9
votes
1answer
152 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 ...
12
votes
3answers
2k 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-...
8
votes
4answers
1k views

JavaScript function that flips brackets direction

I have these strings: )hello( this has ]some text[ flip }any{ brackets even with )))]multiple[((( brackets As you can see, the brackets are all in the wrong ...
8
votes
3answers
280 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 ...
4
votes
3answers
248 views

Check whether a string has all unique characters (time efficiency)

I don't find this algorithm in Go language here, so I just want to check that it is really most efficient algorithm in Go: ...
2
votes
1answer
363 views

Return the first word with the greatest number of repeated letters

I'm learning JavaScript and have written a function that accepts a string and returns the first word with the greatest number of repeated letters. For example: Input:"Hello apple pie" - Output:"Hello"...
8
votes
4answers
868 views

Read string of any length in C

I've written code in C for reading a string of any length, and printing the string. It's one of my first C programs. I posted the program as part of a Stack Overflow question, and received a comment: ...
21
votes
5answers
5k views

Count all vowels in string

For a homework assignment, I was asked to complete this CodeStepByStep problem. It's coded correctly and gave me a right answer. I'm just wondering if there's an easier way to solve this problem ...
4
votes
4answers
251 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 ...
7
votes
2answers
526 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 ...
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 ...
4
votes
1answer
225 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: ...
3
votes
3answers
76 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. ...
8
votes
2answers
8k views

String Similarity using fuzzywuzzy on big data

I have a file in which I was to check the string similarity within the names in a particular column. I use fuzzywuzzy token sort ratio algorithm as it is required for my use case. here is the code, is ...
6
votes
4answers
907 views

First non repeated character

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

Count palindrome substrings

Given a string S, count and return the number of substrings of S that are palindromes. Single length substrings are also palindromes. We just have to count the substring that are palindrome. ...
2
votes
2answers
83 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
848 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 ...
8
votes
5answers
7k views

Find palindromic substrings as efficiently as possible

I've written a function to calculate all the distinct substrings of a given string, that are palindromes. The string is passed as the argument to the function. For example, the string abba is a ...
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: ...
2
votes
1answer
44 views

Embolden parts of auto-complete suggestions that don't match the query

I made a function to embolden text that doesn't match a string, but it appears to be very performance-heavy. I am certain that there are much better ways to do this, but with what I tried, I ran into ...
2
votes
1answer
361 views

Strong Password Checker (Python)

Problem Write a program to return True, if a string is a strong password. A password is considered strong if below conditions are all met: It should have at least ...
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
1answer
2k views

Ashton and String Hackerrank

Online coding challenge Hacker Rank. I tried to solve it using the naive appraoch first but its failing on some of the inputs and rest its getting timed out. How to get started in problem like these ...
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, ...
3
votes
2answers
64 views

I/O-TxtFile Line Distance Program

I am trying to write a lab/program that loops through a .txt input file. Reads an entire line of data as a string, then splits that string into an array delimited by a space. If there are 4 items in ...
3
votes
1answer
373 views

Longest Substring Without Repeating Characters in Scala

Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
5
votes
4answers
198 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 ...

1
2 3 4 5
53