[11 Feb 2020] Remove minimum number of characters so that two strings become anagram
Remove minimum number of characters so that two strings become anagram Given two strings in lowercase, the task is to make them anagram . The only allowed operation is to remove a character from any string. Find minimum number of characters to be deleted to make both the strings anagram? If two strings contains same data set in any order then strings are called Anagrams . Examples : Input : str1 = "bcadeh" str2 = "hea" Output: 3 We need to remove b, c and d from str1. Input : str1 = "cddgk" str2 = "gcd" Output: 2 Input : str1 = "bca" str2 = "acb" Output: 0 // C++ implementation to count number of deletions // required from two strings to create an anagram #include <bits/stdc++.h> using namespace std; const int CHARS = 26; int countDeletions(string str1, string str2) { int arr[CHARS] = {0}; for ( int i = 0; i < str1.length(); i++) ...
https://www.geeksforgeeks.org/zigzag-or-diagonal-traversal-of-matrix/
ReplyDelete