TPHUNTERSCPP Telegram 198
Tp hunters cpp
💬 #چالش 🟥درجه سختی : متوسط 🟢لطفا سوالات , نظرات و کد های خود را برای ما کامنت کنید.
🧠 #کد_چالش
حل توسط : چند نفر از دوستان, اما ساده و بهترین کد کد زیر میباشد.
// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;

// Function to return the count of
// valid indices pairs
int countPairs(string s1, int n1, string s2, int n2)
{

// To store the frequencies of characters
// of string s1 and s2
int freq1[26] = { 0 };
int freq2[26] = { 0 };

// To store the count of valid pairs
int i, count = 0;

// Update the frequencies of
// the characters of string s1
for (i = 0; i < n1; i++)
freq1[s1[i] - 'a']++;

// Update the frequencies of
// the characters of string s2
for (i = 0; i < n2; i++)
freq2[s2[i] - 'a']++;

// Find the count of valid pairs
for (i = 0; i < 26; i++)
count += (min(freq1[i], freq2[i]));

return count;
}

// Driver code
int main()
{
string s1 = "geeksforgeeks", s2 = "platformforgeeks";
int n1 = s1.length(), n2 = s2.length();
cout << countPairs(s1, n1, s2, n2);

return 0;
}
🟢لطفا سوالات, نظرات و کد های خود را برای ما کامنت کنید.



tgoop.com/tphunterscpp/198
Create:
Last Update:

🧠 #کد_چالش
حل توسط : چند نفر از دوستان, اما ساده و بهترین کد کد زیر میباشد.

// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;

// Function to return the count of
// valid indices pairs
int countPairs(string s1, int n1, string s2, int n2)
{

// To store the frequencies of characters
// of string s1 and s2
int freq1[26] = { 0 };
int freq2[26] = { 0 };

// To store the count of valid pairs
int i, count = 0;

// Update the frequencies of
// the characters of string s1
for (i = 0; i < n1; i++)
freq1[s1[i] - 'a']++;

// Update the frequencies of
// the characters of string s2
for (i = 0; i < n2; i++)
freq2[s2[i] - 'a']++;

// Find the count of valid pairs
for (i = 0; i < 26; i++)
count += (min(freq1[i], freq2[i]));

return count;
}

// Driver code
int main()
{
string s1 = "geeksforgeeks", s2 = "platformforgeeks";
int n1 = s1.length(), n2 = s2.length();
cout << countPairs(s1, n1, s2, n2);

return 0;
}
🟢لطفا سوالات, نظرات و کد های خود را برای ما کامنت کنید.

BY Tp hunters cpp




Share with your friend now:
tgoop.com/tphunterscpp/198

View MORE
Open in Telegram


Telegram News

Date: |

"Doxxing content is forbidden on Telegram and our moderators routinely remove such content from around the world," said a spokesman for the messaging app, Remi Vaughn. Hui said the messages, which included urging the disruption of airport operations, were attempts to incite followers to make use of poisonous, corrosive or flammable substances to vandalize police vehicles, and also called on others to make weapons to harm police. Today, we will address Telegram channels and how to use them for maximum benefit. To upload a logo, click the Menu icon and select “Manage Channel.” In a new window, hit the Camera icon. Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020.
from us


Telegram Tp hunters cpp
FROM American