Transform String || GeeksforGeeks || Problem of the Day || Must Watch
ฝัง
- เผยแพร่เมื่อ 27 ต.ค. 2024
- Transform String || GeeksforGeeks || Problem of the Day || Must Watch
Join us at telegram: telegram.me/pl...
For all GFG courses
get 10% Discount using Coupon code : STUDYWITHSAUMYA
Problem (GFG) : practice.geeks...
CODE LINK : github.com/Sau...
#CodingInterview #GFGPractice #GeeksforGeeks #PracticeProblems #CodingQuestions #leetcode #coding #programming #coding #bfs #graphs #graph #djikstra #gfg #programming #coding #dsa #stack #queue #tree #bst #heap #maxheap #dfs #bfs #backtracking
All test cases are not passed in GFG from your code
Good Explaination !!! but i have a doubt if s1="geeksforgeeks" and s2 = "rfogeeksgeeks" , then according to your approach it gives 3 output. but in real s1 never be equal to s2 in 3 operation .
I hope u reply me as the earlist
it is possible bro , let me explain first remove o and insert in the beginning and then in 2nd turn remove f and insert in the beginning and at last remove r and then insert in the beginning so total 3 steps, i hope you understood this way
actually we are not doing the actual change in string. we are just figuring out how many characters are miss placed.
similear with ABGH CDEF
Az and By has same ascii samation : >
agr koi 0(256) space use krta hai to wo constant 0(1) use kr rha hota hai
It's failing at when String A = "anod" and String B = "mpad". Because, even if the sum of the ascii characters are same but their might be case when the character are not same. That's the reason this solution is not valid for all the test cases.
use map
yes
Expected Auxiliary Space: O(1) according to GFG@@shresthrakesh702
Your code can not pass last test case
It'll fail this test case
a = "bbc" b = "cca"
cuz summation is equal but it's still impossible to convert a to b. Map should be used to check for anagrams.
if you dont want extra space for checking anagrams
we can simply sort it and check whether they are equal or not
@@tarundatwani8427 Sorting too, will take an extra linear space, atleast in case of Java. Though I tried submitting my solution (with HashMaps), and interestingly gfg passed it, without any extra space warning 🤷🏾♀
before posting the video run the code and verify it. because they asked minimum number of transformation
int transform (string A, string B)
{
if(A.size()!=B.size())
return -1;
int i = A.size()-1 , j= A.size()-1 , cnt = 0 ;
map m1 ,m2 ;
for(int i = 0 ; i=0)
{
if(A[i]==B[j])
{
i--;
j--;
}
else
{
cnt++;
i--;
}
}
return cnt;
}
getting compilation error at line no. 41, 46 n 58.....
Hello Madan,
The answer of why you are saying Array is that you are speaking too fast and it usually appears as array as it is from index 0 to N 😀
wrong solution don't post fake or wrong videos if you don't know the correct solution
anod mpad pe galat hai ye
anod mpad same .
can, any one correct this code ?
Really helped a lot!!
Your Solution is Wrong , Please do not upload such wrong solution and waste our time !
Please give solution in python also
Could you please make a video on reverse string
wait a minute --------you Sound like Striver
Good Explanation 👍
Thanks 🙂
Nice Explaination . Thank you Saumya.
Glad you liked it
this stupid video took a lot of my time
koi nhi thodi galti maaf h
but samjhati acha ho 😋
Fails when A = "anod" , B = "mpad",
only this test case fails