Thank you so much for your course I couldn't buy any paid course and thought that I couldn't learn all the coding and ds algo but with your course iam learning all of them thank you so much ❤️❤️👍👍👍
7:19 Alternate way, we will sort our string(asc. order) then we'll compare the two consecutive charaters if true the count = count + 1 or else count = 1, initially our count is 1 st = 0; en = 1, for checking the consecutive two elements, if the two elements are same then we'll increment both st and en by 1 for checking the next if the both elements are same then len++ or else len = 1 consecutive elements here is the code #include #include #include using namespace std; int main(){ string str; cin >> str; int st=0; int en=1; int len=1; int mxLen=INT_MIN; sort(str.begin(),str.end()); cout
we can also do the last question by sorting the string and then iterate through it.... #include #include #include using namespace std; int main(){ string s1="abcaacbade"; sort(s1.begin(),s1.end()); int freq=1; int maxf=0; for(int i=0;i
@bestvideos8473 one letter is coming atleast we cannot say zero as letters are there. Though every letter is different ,max frequency is 1.So ,intialise with 1.
Additional question.. //compression of string //remove the repeating consecutive characters. int main() { string s; cin>>s; for (int i = 1; i < s.size(); i++) { if (s[i]==s[i-1]) { s.erase(i-1,1); --i; } } cout
0:00 - Ads 3:54 - Inbuilt function ( Transform func.) 5:54 - form the biggest number from the numeric string 7:22 - maximum number occuring in string(maximum frequent character/number)
Q1. Convert to UPPER or lower: 0:10 Shortcut - transform() function : 4:00 Q2. Form the biggest number from the numeric string : 5:48 Doubt - Why do we use greater()? What does it mean? Q3. Output Frequency : 7:15
value intialize given in the ques. that are the no. of alphabets, else you can put freq[n] = {0}; but al last u have make dession driver in which u have to place value of n ao else you cannot input value in the output menu.
I have think an another way of doing the first question and I think that it's the easiest way to do this question at this level --------------- #include using namespace std; int main() { string s1; cin>>s1; for(int i=0; i
for last question: #include using namespace std; int main(){ int t; cin>>t; while(t--){ string s; cin>>s; int freq[26]={0}; int max=0;char result; for(int i=0;i
Q2) This is the answer of Q2, using for loop, and the STL as well: - #include #include #include using namespace std; int main() { string a; getline (cin, a); // for (int i = 0; i < a.length(); i++) // { // for (int j = i + 1; j < a.length(); j++) // { // if (a[i] < a[j]) // { // int temp = a[i]; // a[i] = a[j]; // a[j] = temp; // } // } // } USE THE ABOVE CODE OR THE CODE BELOW! BOTH FUNCTION IN THE EXACT SAME MANNER! sort (a.begin(), a.end(), greater()); // this sorts the string in a descending order!! cout
@@Niketh.M actually I wanted to do android development. So that's why. C/C++ were languages I started because I wanted to know what is programming. Once got comfortable with loops and started understanding oops then I moved to Java.
The last question will not work if capital characters and small characters are in mixture so the general solution is..,......for question no. 3rd #include using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif string str; getline(cin,str); int mx=INT_MIN; int length=str.size(); int count; char st; for(int i=0;i
Wap to accept a string from user and return a word from string which have greatest number of repeated character..also prinnt the character.. Ex input: hello assesment team Output:Assesment Char :S Count 3 Can u solve this???? I will wait for solution
In the description of the video PDF notes links are there , in some videos i was opened it there was not any PDF and showing -Sorry, the file you have requested does not exist. Please reply any one who face this type of issues and tell what is the solution.
actually its not. The time complexity of sort func is O(nlogn) which makes total time complexity as O(nlogn + n) whereas the the complexity of code in the video is O(3n) which is more efficient. Thank for the idea though
IN MAXIMUM REPEATING LETTER QUESTION, WE CAN FIRST SORT THE STRING THEN FIND THE LONGEST CONTIGOUS SUBSTRING WHICH WAS DISSCUSED IN A PREVIOUS VIDEO OF ARRAY;
i can also do the last question by sorting the string and then iterate through it ...... #include #include #include using namespace std; int main() { string s = "abcacbadbbe"; sort(s.begin(),s.end()); cout
Here is very easy solution for last question in O(n) time complexity #include #include #include int main() { int a = 1, mx = INT_MIN, p; string s = "abdbcaabb"; sort(s.begin(), s.end()); for (int i = 0; i mx) { p = i; } mx = max(mx, a); } cout
We need to do in the way taught by bhaiya ,bcz if we try other method our time complexity is becoming order of stringsize ,but for bhaiya its only O(52).
In the last ques we could have sorted the string using sort(s.begin(), s.end()) and then get the char with the max frequency. This is my approach hope u liked it.
@@GajendraSingh-lv3jw bro like in the second ques bhaiya stated sort method to sort a string we can sort it from that then we can calculate the frequency of max
ab aisa hai vaiya ap ki coding ko samjne ke liye dubara video dekhna hota hai...lekin jab samaj mai ajata hai atab dil se awaj ata hai "arey wah bete maj kar di"....
code for java class Rough{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s ; System.out.println("Enter the value of String"); s = sc.nextLine(); int arr[] = new int[256]; //256 is the last number in ascii table(tables which has int value of all the possible characters) int n = s.length(); for(int i=0 ; i
everything is fine but in notes to convert string into lower/upercase the conditional statement is having or operator, it should be and operator as mentioned in the lecture.
In Third Question A string may have multiple characters with maximum frequency so for the code in the video I hope it won't display all the characters in a string which has maximum frequency ,also I think that code won't work for alphanumeric & strings with special characters. So I wrote my code using ascii values and also using in-built function to find the the max element in a array My Solution #include "bits/stdc++.h" using namespace std; int main() { int ar[256]={0}; int n = sizeof(ar) / sizeof(ar[0]); string str; cout
My Approach For the third challenge ( Max frequency ) . Comments down if it is good (in terms of time complexity) than the following approach should in the tutorial. #include using namespace std; int main(){ int n, i, j, Max=0, counter=0 ; cout n; char arr[n+1] ; cout arr; for (i=0; i
for question no 3 without the ascii we can solve it by first sorting string and then taking the element which has highest frequency #include using namespace std; int main() { string s, m, n; int count = 0, c_max = 0; cin >> s; n = s[0]; sort(s.begin(), s.end()); cout
In Last question if 2 different character have max frequency then output is only one according to code that sir has written Plz someone help me to write complete code
Not saying anything controversial but this shows the hollowness of us , Indian student , It seems that our resolve to code changes as far we go from bhaiya's motivational video . Everyone was hyped up now no.s are dying tho hope Aman sir continues ! Others will soon comment after 2-3 yrs hamien kisi ne bataaya hi nahi !