🌐
Reddit
reddit.com › r/cprogramming › most commonly asked string questions in c.
r/cprogramming on Reddit: Most commonly asked string questions in C.
November 20, 2023 -

Hello Everyone,

I am currently interviewing for Embedded/Firmware-related jobs. Strings are not my strongest suit. So far, I have been asked to check if a given string is a palindrome or not. However, since I started doing LeetCode, I have been struggling the most with string-related questions, especially those involving substrings.

What have been the most common interview questions you've been asked, particularly those involving strings?

🌐
HackerRank
hackerrank.com › interview › interview-preparation-kit › strings › challenges
Solve String Manipulation Interview Questions | HackerRank
Please read our cookie policy for more information about how we use cookies. Ok · Prepare · Interview Preparation Kit · String Manipulation · How many characters should one delete to make two given strings anagrams of each other?
🌐
IndiaBIX
indiabix.com › technical › c › strings
Strings - C Programming Interview Questions and Answers
This has the effect of right-justifying the input string. Finally, because the strdup() function dynamically allocates memory, the free() function is called to free up the memory taken by the duplicate string. Check out the latest current affairs questions and answers. Check out the latest interview questions and answers.
🌐
Aticleworld
aticleworld.com › home › top 15 string interview questions in c, might ask by the interviewer.
Top 15 string Interview Questions in C, might ask by the interviewer. - Aticleworld
January 1, 2020 - Suppose if input string is pString , pString = “silence is a source of great strength” ; /* input string */ ... Copy the *(pString + startIndex) character in resultant string.
🌐
w3resource
w3resource.com › c-programming-exercises › string › index.php
C programming exercises: String - w3resource
Test Data : Check the length of two strings: -------------------------------- Input the 1st string : aabbcc Input the 2nd string : abcdef String1: aabbcc String2: abcdef Expected Output : Strings are not equal.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › top-50-string-coding-problems-for-interviews
String Coding Interview Questions - GeeksforGeeks
September 18, 2025 - String-related problems often assess a candidate's understanding of concepts like pattern matching, manipulation, and efficient algorithm design. Here is the collection of frequently asked interview questions on Strings. Problems in this Article are divided into three Levels so that readers ...
🌐
Oops Info Solutions
oopsinfosolution.com › home › string interview questions
String Interview Questions | Oops Info Solutions Pvt. Ltd.
November 7, 2017 - Knowing answers to these questions will be very helpful to tackle any questions asked related to String in interview. int main() { char str[1000], ch; int i, freQuency = 0; printf("Enter a string: "); gets(str); printf("Enter a character to find the frequency: "); scanf("%c",&ch); for(i = 0; str[i] != '\0'; ++i) { if(ch == str[i]) ++freQuency; } printf("Frequency of %c = %d", ch, frequency); return 0; }
🌐
Techie Delight
techiedelight.com › home › string – interview questions and practice problems
String – Interview Questions and Practice Problems | Techie Delight
September 12, 2025 - Find the longest even-length palindromic sum substring of a stringMedium ... Average rating 4.82/5. Vote count: 56 · No votes so far! Be the first to rate this post. We are sorry that this post was not useful for you! Tell us how we can improve this post? Submit Feedback ... Thanks for reading. To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.
🌐
Medium
medium.com › @akabaridixit009 › top-string-coding-interview-questions-and-answers-part-1-ac46cf964cc7
Top String Coding Interview Questions and Answers | Medium
August 29, 2024 - Input: let str1 = "listen" let str2 = "silent" Expected Output: True Input: let str1 = "allergy" let str2 = "allergic" Expected Output: False ... This approach sorts the characters of both strings and compares the sorted versions.
Find elsewhere
🌐
Reddit
reddit.com › r/cscareerquestions › string manipulation questions
r/cscareerquestions on Reddit: String manipulation questions
May 3, 2024 -

Howdy! I have an interview coming up in 2 weeks and wanted to practice string manipulation(as it was hinted that’s what I’d be tested on).

I’ve practiced a few already but mostly been seeing similar 2 pointer ones. Does anyone have any other questions they recommend to just practice string manipulation or string parsing that isn’t the typical reverse a string?

I’m trying to compile a few more problems to practice and hope to be ready.

Top answer
1 of 3
9

Both results in undefined behaviour.

The first is because you are using a pointer (str) after free'ing it (free() doesn't/can't set the pointer to NULL after being the block).

The second because you are using a pointer to a local variable from another function.

2 of 3
4

Both examples contain the same type of error, using an object after its lifetime has ended.

Doing so results in undefined behavior1. The text uses the word 'referred', which basically means accessing an object or using an identifier of said object.

What actually causes undefined behavior in both examples isn't the rule mentioned above1, but another one, which is closely related. The value of a pointer which points to an object whose lifetime has ended is indeterminate2. Reading such values causes undefined behavior. This happens in both examples.

In the first example, the lifetime of str ends at the call to free. The pointer is then used in the if statement if(str != NULL){ which causes undefined behavior.

In the second example, the lifetime of p ends when the function returns. The returned pointer is assigned to a pointer str: str = GetMemory();, which causes undefined behavior.


1 (Quoted from: ISO/IEC 9899:201x 6.2.4 Storage durations of objects 2)
If an object is referred to outside of its lifetime, the behavior is undefined.

2 (Quoted from: ISO/IEC 9899:201x 6.2.4 Storage durations of objects 2)
The value of a pointer becomes indeterminate when the object it points to (or just past) reaches the end of its lifetime.

🌐
Technoname
technoname.com › home › string coding questions with solutions.
String Coding Questions with solutions. - Technoname
September 29, 2021 - This blog covers all the string coding questions might be asked in any of your interviews or coding round and will improve practical knowledge.
🌐
Quora
quora.com › What-are-the-most-important-string-manipulation-questions-every-Computer-Science-student-should-know
What are the most important string manipulation questions every Computer Science student should know? - Quora
Some good questions on string manipulation are: 1. Check if string is palindrome or not 2. Reverse a string without recursion and temp space. 3. Finding a substring in a String with best space and time complexity.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › string-c-cpp-programs
String C/C++ Programs - GeeksforGeeks
July 23, 2025 - C/C++ Program for Remove characters from the first string which are present in the second string C/C++ Program for A Program to check if strings are rotations of each other or not C/C++ Program for Print reverse of a string using recursion C/C++ ...
🌐
Tech Interview Handbook
techinterviewhandbook.org › string
String cheatsheet for coding interviews | Tech Interview Handbook
Ask about input character set and case sensitivity. Usually the characters are limited to lowercase Latin characters, for example a to z. ... Many string questions fall into one of these buckets.
🌐
Medium
medium.com › javarevisited › top-21-string-programming-interview-questions-for-beginners-and-experienced-developers-56037048de45
Top 21 String Programming Interview Questions for Beginners and Experienced Developers | by javinpaul | Javarevisited | Medium
2 weeks ago - In this article, I am going to share some of the most common String based coding problems I have come across from many Programming interviews I have been part of. I also have experience from both sides of the table as a candidate as well as the Interviewer, so I know how important these questions are.
🌐
IGotAnOffer
igotanoffer.com › blogs › tech › string-interview-questions
51 string interview questions (coding problems with solutions) - IGotAnOffer
June 29, 2022 - List of string questions for coding interviews with links to high-quality solutions, plus a string refresher and cheat sheet.