Top 20 String Coding Problems from Programming Job Interviews
Tags: programming, java, beginners, computerscience
Published: 2019-06-01 08:58:33

---
title: Top 20 String Coding Problems from Programming Job Interviews
published: true
description: A list of frequently asked String based coding problems from Programming Job Interviews.
tags: programming,java,beginners,computerscience
---
*Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided in this article.*

[![](https://cdn-images-1.medium.com/max/1000/1*ikKSYqB3U5Ms9e4fYoRg8w.png)](https://www.udemy.com/course/data-structures-and-algorithms-deep-dive-using-java/?LSNPUBID=JVFxdTr9V80&ranEAID=JVFxdTr9V80&ranMID=39197&ranSiteID=JVFxdTr9V80-HtAKxsXlpXTUmaSiBItBww)
Along with [array](http://www.java67.com/2018/02/10-examples-of-array-in-java-tutorial.html), [binary tree](https://javarevisited.blogspot.com/2015/10/how-to-implement-binary-search-tree-in-java-example.html), and [linked list](https://javarevisited.blogspot.com/2017/07/top-10-linked-list-coding-questions-and.html) data structures, the **string** is another popular topic on programming job interviews. I have never participated in a coding interview where no [string-based questions](http://www.java67.com/2018/04/21-string-programming-and-coding-interview-questions-answers.html) were asked.

This is very obvious because I have also never written a program where I have not used a single String variable. You will always find String as one of the most used data type or data structure in any program.

In this article, I am going to share some of the most common [String based coding problems](http://www.java67.com/2018/04/21-string-programming-and-coding-interview-questions-answers.html) 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 an Interviewer so I know how important these questions are.

Btw, there is no point in solving these questions if you don't have basic knowledge of [data structure](https://medium.com/javarevisited/7-best-courses-to-learn-data-structure-and-algorithms-d5379ae2588) or you have not to refresh them in recent times. In that case, I suggest you first go through a good data structure and algorithm course or book to revise the concept.

This will save you a lot of time going back and forth between the book and your IDE for each question.

If you need resources, I suggest following [online courses to learn Data structure and Algorithms](https://javarevisited.blogspot.com/2018/11/top-5-data-structures-and-algorithm-online-courses.html), even though they are independent of any programming language, I strongly suggest you join the course which explains problems in the programming language you are most comfortable with.

Like

1.  [**Data Structures and Algorithms: Deep Dive Using Java**](https://click.linksynergy.com/fs-bin/click?id=JVFxdTr9V80&subid=0&offerid=323058.1&type=10&tmpid=14538&RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdata-structures-and-algorithms-deep-dive-using-java%2F) for Java developers
2.  [**Algorithms and Data Structures in Python**](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Falgorithms-and-data-structures-in-python%2F) for those who love Python
3.  [**JavaScript Algorithms and Data Structures Masterclass**](https://click.linksynergy.com/fs-bin/click?id=JVFxdTr9V80&subid=0&offerid=508237.1&type=10&tmpid=14538&RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fjs-algorithms-and-data-structures-masterclass%2F) by Colt Steele for JavaScript programmers
4.  [**Mastering Data Structures & Algorithms using C and C++**](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fdatastructurescncpp%2F) for those who are good at C/C++

## How to solve String based Coding Problems?
A good thing about the string data structure is that if you know the array data structure, you can easily solve string-based problems because **strings are nothing but a character array**.

> So all the techniques you know by solving [array-based coding questions](https://javarevisited.blogspot.com/2015/06/top-20-array-interview-questions-and-answers.html) can be used to solve string programming questions as well.

Here is my list of some of the frequently asked string coding questions from programming job interviews:

1.  **How do you reverse a given string in place? (**[**solution**](http://www.java67.com/2016/06/how-to-reverse-string-in-place-in-java.html)**)**
2.  **How do you print duplicate characters from a string? (**[**solution**](http://java67.blogspot.sg/2014/03/how-to-find-duplicate-characters-in-String-Java-program.html)**)**
3.  **How do you check if two strings are anagrams of each other? (**[**solution**](http://javarevisited.blogspot.sg/2013/03/Anagram-how-to-check-if-two-string-are-anagrams-example-tutorial.html)**)**
4.  **How do you find all the permutations of a string? (**[**solution**](http://javarevisited.blogspot.com/2015/08/how-to-find-all-permutations-of-string-java-example.html)**)**
5.  **How can a given string be reversed using recursion? (**[**solution**](http://javarevisited.blogspot.sg/2012/01/how-to-reverse-string-in-java-using.html)**)**
6.  **How do you check if a string contains only digits? (**[**solution**](http://javarevisited.blogspot.sg/2012/10/regular-expression-example-in-java-to-check-String-number.html)**)**
7.  **How do you find duplicate characters in a given string? (**[**solution**](http://java67.blogspot.sg/2014/03/how-to-find-duplicate-characters-in-String-Java-program.html)**)**
8.  **How do you count the number of vowels and consonants in a given string? (**[**solution**](http://java67.blogspot.sg/2013/11/how-to-count-vowels-and-consonants-in-Java-String-word.html)**)**
9.  **How do you count the occurrence of a given character in a string? (**[**solution**](http://javarevisited.blogspot.sg/2012/12/how-to-count-occurrence-of-character-in-String.html)**)**
10. **How do you print the first non-repeated character from a string? (**[**solution**](http://javarevisited.blogspot.sg/2014/03/3-ways-to-find-first-non-repeated-character-String-programming-problem.html)**)**
11. **How do you convert a given String into int like the atoi()**? ([**solution**](https://javarevisited.blogspot.com/2011/08/convert-string-to-integer-to-string.html))
12. **How do you reverse words in a given sentence without using any library method? (**[**solution**](http://java67.blogspot.com/2015/06/how-to-reverse-words-in-string-java.html)**)**
13. **How do you check if two strings are a rotation of each other? (**[**solution**](http://www.java67.com/2017/07/string-rotation-in-java-write-program.html)**)**
14. **How do you check if a given string is a palindrome? (**[**solution**](http://java67.blogspot.com/2015/06/how-to-check-is-string-is-palindrome-in.html)**)**
15. **How do you find the length of the longest substring without repeating characters? (solution)**
16. **Given string str, How do you find the longest palindromic substring in str? (solution)**
17. **How to convert a byte array to String? (**[**solution**](https://javarevisited.blogspot.com/2014/08/2-examples-to-convert-byte-array-to-String-in-Java.html)**)**
18. **how to remove the duplicate character from String? (**[**solution**](https://javarevisited.blogspot.com/2016/06/how-to-remove-duplicate-characters-from-String-Java.html)**)**
19. **How to find the maximum occurring character in a given String? (**[**solution**](http://javarevisited.blogspot.com/2012/12/how-to-count-occurrence-of-character-in-String.html)**)**
20. **How do you remove a given character from String? (**[**solution**](http://java67.blogspot.com/2013/03/how-to-replace-string-in-java-character-example.html)**)**

These questions help improve your knowledge of string as a data structure.

> If you can solve all these String questions without any help then you are in good shape.

For more advanced questions, I suggest you solve problems given in the[**Algorithm Design Manual by Steven Skiena**](http://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena/dp/1849967202?tag=javamysqlanta-20), a book with the toughest algorithm questions.

[![](https://cdn-images-1.medium.com/max/1000/0*En9lunE6XQ3uaycc.jpg)](http://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena/dp/1849967202?tag=javamysqlanta-20)

If you need to revise your Data Structure and Algorithms concepts then you can also see these resources:

[**1\. Data Structures and Algorithms: Deep Dive Using Java**](https://click.linksynergy.com/fs-bin/click?id=JVFxdTr9V80&subid=0&offerid=323058.1&type=10&tmpid=14538&RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdata-structures-and-algorithms-deep-dive-using-java%2F) for Java developers

[**2\. Algorithms and Data Structures in Python**](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Falgorithms-and-data-structures-in-python%2F) for those who love Python

[**3\. JavaScript Algorithms and Data Structures Masterclass**](https://click.linksynergy.com/fs-bin/click?id=JVFxdTr9V80&subid=0&offerid=508237.1&type=10&tmpid=14538&RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fjs-algorithms-and-data-structures-masterclass%2F)by Colt Steele for JavaScript programmers

[**4\. Mastering Data Structures & Algorithms using C and C++**](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fdatastructurescncpp%2F) for those who are good at C/C++

These are some of the best courses on data structures and algorithms and you can choose the one which is most suitable for you. Btw, I will receive payments if you buy these courses


### Now You're Ready for the Coding Interview
These are some of the most common questions outside of data structure and algorithms that help you to do really well in your interview.

I have also shared a lot of these questions on my [javarevisited](http://javarevisited.blogspot.com/) and [java67](http://java67.com/), so if you are really interested, you can always go there and search for them.

These **common String based questions** are the ones you need to know to successfully interview with any company, big or small, for any level of programming job.

If you are looking for a programming or software development job in 2018, you can start your preparation with this list of coding questions but you need to prepare other topics as well.

This list of [**50+ data structure and algorithms problems**](https://hackernoon.com/50-data-structure-and-algorithms-interview-questions-for-programmers-b4b1ac61f5b0) provides good topics to prepare and also helps assess your preparation to find out your areas of strength and weakness.

Good knowledge of data structure and algorithms is important for success in coding interviews and that's where you should focus most of your attention.

**Further Learning**
[10 Algorithm Books Every Programmer Should Read](http://www.java67.com/2015/09/top-10-algorithm-books-every-programmer-read-learn.html)
[Top 5 Data Structure and Algorithm Books for Java Developers](http://javarevisited.blogspot.sg/2016/05/5-free-data-structure-and-algorithm-books-in-java.html#axzz4uXETWjmV)
[From 0 to 1: Data Structures & Algorithms in Java](https://click.linksynergy.com/fs-bin/click?id=JVFxdTr9V80&subid=0&offerid=323058.1&type=10&tmpid=14538&RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Ffrom-0-to-1-data-structures%2F)
[Data Structure and Algorithms Analysis --- Job Interview](https://click.linksynergy.com/fs-bin/click?id=JVFxdTr9V80&subid=0&offerid=323058.1&type=10&tmpid=14538&RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdata-structure-and-algorithms-analysis%2F)
[50+ Data Structure and Coding Problems for Programmers](https://dev.to/javinpaul/50-data-structure-and-algorithms-problems-from-coding-interviews-4lh2)
[10 Data Structure, Algorithms and SQL Courses to Crack Coding Interviews](https://dev.to/javinpaul/10-data-structure-algorithms-sql-and-java-courses-to-crack-any-programming-job-interview-11f6)
[20+ Array Coding Problems for Programmers](https://medium.com/javarevisited/20-array-coding-problems-and-questions-from-programming-interviews-869b475b9121)
[20+ Linked List Coding Problems for Programmers](https://medium.com/javarevisited/top-20-linked-list-coding-problems-from-technical-interviews-90b64d2df093)
[25+ System Design Coding Problems for interviews](https://medium.com/javarevisited/25-software-design-interview-questions-to-crack-any-programming-and-technical-interviews-4b8237942db0)

#### Closing Notes

Thanks, You made it to the end of the article ... Good luck with your programming interview! It's certainly not going to be easy, but you are one step closer after practicing these questions.

If you like this article, then please share it with your friends and colleagues, and don't forget to follow [javinpaul](https://twitter.com/javinpaul) on Twitter!

> **P.S. --- If you need some FREE resources for Programming Job Interviews, you can check out this list of** [**free data structure and algorithm courses**](http://javarevisited.blogspot.com/2018/01/top-5-free-data-structure-and-algorithm-courses-java--c-programmers.html) **to start your preparation.**