Questions related to strings

Remove “b” and “ac” from a given string

Given a string, eliminate all “b” and “ac” in the string, you have to replace them in-place, and you are only allowed to iterate over… Read More »

Longest Common Substring | DP-29

Given two strings ‘X’ and ‘Y’, find the length of the longest common substring. Examples : Input : X = “GeeksforGeeks”, y = “GeeksQuiz” Output… Read More »

Minimum insertions to form a palindrome | DP-28

Given a string str, the task is to find the minimum number of characters to be inserted to convert it to palindrome. Before we go… Read More »

Karatsuba algorithm for fast multiplication using Divide and Conquer algorithm

Given two binary strings that represent value of two integers, find the product of two strings. For example, if the first bit string is “1100”… Read More »

The atoi() function in C takes a string (which represents an integer) as an argument and returns its value of type int. So basically the… Read More »

String matching where one string contains wildcard characters

Given two strings where first string may contain wild card characters and second string is a normal string. Write a function that returns true if… Read More »

Counting Sort

Counting sort is a sorting technique based on keys between a specific range. It works by counting the number of objects having distinct key values… Read More »

Generate n-bit Gray Codes

Given a number n, generate bit patterns from 0 to 2^n-1 such that successive patterns differ by one bit. Examples: Following is 2-bit sequence (n… Read More »

Count words in a given string

Given a string, count number of words in it. The words are separated by following characters: space (‘ ‘) or new line (‘\n’) or tab… Read More »

Write your own strcmp that ignores cases

Write a modified strcmp function which ignores cases and returns -1 if s1 < s2, 0 if s1 = s2, else returns 1. For example,… Read More »

Program to validate an IP address

Write a program to Validate an IPv4 Address. According to Wikipedia, IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers,… Read More »

I am a final year student of IIT Guwahati and the first phase of placements has just finished at our college. I was recruited by… Read More »

Given a sequence of words, print all anagrams together | Set 2

Given an array of words, print all anagrams together. For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then output may be… Read More »

Given a sequence of words, print all anagrams together | Set 1

Given an array of words, print all anagrams together. For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then output may be… Read More »

Longest Palindromic Substring | Set 2

Given a string, find the longest substring which is palindrome. For example, if the given string is “forgeeksskeegfor”, the output should be “geeksskeeg”. Recommended: Please… Read More »