Skip to content

Latest commit

 

History

History

string

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

String

A char array is just that - an array of characters:

  • If allocated on the stack (like in your example), it will always occupy eg. 256 bytes no matter how long the text it contains is
  • If allocated on the heap (using malloc() or new char[]) you're responsible for releasing the memory afterwards and you will always have the overhead of a heap allocation.
  • If you copy a text of more than 256 chars into the array, it might crash, produce ugly assertion messages or cause unexplainable (mis-)behavior somewhere else in your program.
  • To determine the text's length, the array has to be scanned, character by character, for a \0 character.

A string is a class that contains a char array, but automatically manages it for you. Most string implementations have a built-in array of 16 characters (so short strings don't fragment the heap) and use the heap for longer strings.


Minimum number of deletions to make pallindromicsubstring:

There are two ways to solve this problem:

  • A simple solution is to remove all subsequences one by one and check if the remaining string is palindrome or not. The time complexity of this solution is exponential.

  • An efficient approach uses the concept of finding the length of the longest palindromic subsequence of a given sequence.

  • Checking for Anagram of two string ---->Java
  • Convert string to lowercase and uppercase ---->C++
  • Kth Minimum in array ---->Python
  • Longest Common Prefix ----> Java
  • Longest Palindromic Substring ----> Python
  • Longest Prefix Suffix Problem ---->C++
  • Manacher's algorithm (finding the longest palindrome in a string) ----> Java
  • Maximum occuring character in a string ---->C++
  • Number of deletions to make a string pallindrome ---->Python
  • Print Shortest Common Supersequence ---->Java
  • Remove Invalid Parentheses ----> C++
  • Reverse a string ---->C++ | Java
  • Reverse a string using Stack ---->C++
  • Reverse Individual Words in String ----> Java
  • Maximum occuring character in a string ---->C++
  • Checking for Anagram of two string ---->Java
  • Pig Latin Converter ----> Java