(HARD?) LeetCode Day 9 - Backpace String Compare in O(1) Space

We need to compare two modified strings in O(1) space. This was quite difficult for me but hey, maybe that's a good thing.
Leetcode holds a 30-day Challenge in April with a new coding interview problem appearing each day, here's contest link: leetcode.com/explore/featured...
Subscribe for more educational videos on algorithms, coding interviews and competitive programming.
- Github repository: github.com/Errichto/youtube
- Live streams on 2nd YT channel and on Twitch: / errichto2 & / errichto
- FB and Twitter: / errichto & / errichto
- Frequently Asked Questions: github.com/Errichto/youtube/w...
#Coding #Programming

Пікірлер: 182

  • @Errichto
    @Errichto4 жыл бұрын

    Oh shit. It is possible to get O(1) space without modifying the input strings. Hint: go through strings in reverse. Full solution: leetcode.com/problems/backspace-string-compare/solution/

  • @dr.darkfurygaming9174

    @dr.darkfurygaming9174

    4 жыл бұрын

    Hey I'm your daily viewer atleast you should give me heart 😇😇

  • @Errichto

    @Errichto

    4 жыл бұрын

    @@dr.darkfurygaming9174 I gave you a like. Next time write something funny and more relevant to the video, then you might get a heart. That's the rules :D

  • @rockycooldude4889

    @rockycooldude4889

    4 жыл бұрын

    yesssssssssssssssssssssssssssss....i beat you...i feel so fucking awesome...............................................i cant fucking believe it .........lol....it felt so obvious to go reverse(even though i know "obvious" is relative)........but ...that's what i was thinking while watching the video..why is he not thinking like this(but then i thought maybe i am stupid and there is a better way..xd...

  • @pskd73

    @pskd73

    4 жыл бұрын

    I thought you would finish it in one minute. I took some 10 minutes. I feel satisfied. Anyways, I really like your videos. There are other people, who make videos for money or something else, but you, (y)

  • @justlola7402

    @justlola7402

    4 жыл бұрын

    Hey, I think we can go either forward (left to right) or reverse (right to left), seems going in reverse is easier

  • @MojahooProducer
    @MojahooProducer4 жыл бұрын

    oh noooo, you really shaved it off and wont reveal yourself :((

  • @Dylan-xc8yz
    @Dylan-xc8yz4 жыл бұрын

    Thank you for your videos Errichto. I enjoy watching you code and see how you think; it helps to improve my code.

  • @maharshrp
    @maharshrp4 жыл бұрын

    I used a pointer approach. Have a pointer for both strings that goes from right to left. If it’s a #, then move left and keep track of how many #s were encountered and skip that many digits. Do the same for the other string. If the values are the same at both pointers, go left on both and keep repeating the process until the end. If they aren’t equal then exit out. At the end check that both pointers are -1 otherwise they are different strings.

  • @iiju8212

    @iiju8212

    4 жыл бұрын

    Would you like to share your solution? newbie here. A bit confused about your approach. Thanks.

  • @Aditya-us5gj

    @Aditya-us5gj

    4 жыл бұрын

    @@iiju8212 look at the first comment by Errichto. Always try your best to solve otherwise move to editorials. Don't ask for others solution buddy, editorials are best as they will do complexity analysis and will discuss all approaches.p

  • @shaypatrickcormac2765

    @shaypatrickcormac2765

    4 жыл бұрын

    yeah, i think everyone else use this approach. But Errichto always solving problems in counterintuitive way some how

  • @Errichto

    @Errichto

    4 жыл бұрын

    @@shaypatrickcormac2765 Interesting opinion. On which of the previous 8 days did I use some unusual or counterintuitive approach?

  • @andreykarayvansky9549

    @andreykarayvansky9549

    4 жыл бұрын

    @@shaypatrickcormac2765 using stack was actually the simplest approach. But it required extra memory. Most likely, since he is a competitive programmer it's natural for him to find to look for the simplest and known solution. Moving backwards has a tonne of corner cases.

  • @kaotony4068
    @kaotony40684 жыл бұрын

    Thank you do showing the whole think process and not jumping to the best solution result :)

  • @MrStar1102
    @MrStar11024 жыл бұрын

    Haha, looking at you struggle with this problem makes me feel much better about myself. There are problems that take me hours to solve, and you just need like 1-2 minutes to solve them, the feeling of watching you do it just makes me want to quit already, haha, but finally, I have the feeling that I'm faster than you, even just once, that's just great. You're the best. Thanks for the inspiration.

  • @AAAAAA-gj2di

    @AAAAAA-gj2di

    2 жыл бұрын

    Yup...sometimes I feel awesome if I notice few silly mistakes in his code before him

  • @kruschiii
    @kruschiii4 жыл бұрын

    Well now you will probably get to 100k subs within minutes! We cannot stand the tension!

  • @uthamkanth2505

    @uthamkanth2505

    4 жыл бұрын

    kruschiii The concept is very well explained in this video infact i have my channel which has similar content.pls check, subscribe and show me your support if u like them and give me u r feedback in comment section.thank you:)

  • @srinjoychoudhury2246
    @srinjoychoudhury22464 жыл бұрын

    First time I solved something faster than you without modifying the strings. Thanks for motivating.

  • @themispapavasileiou7872
    @themispapavasileiou78724 жыл бұрын

    hearing you think along helps. thanks for another one!

  • @AlekseiMaide
    @AlekseiMaide4 жыл бұрын

    Really happy to see that you are actually a human! great video, keep it up!

  • @adarshkashyap8715

    @adarshkashyap8715

    4 жыл бұрын

    :p true

  • @junminstorage
    @junminstorage4 жыл бұрын

    Finally, we found out you are still human. :)

  • @B0JACK
    @B0JACK4 жыл бұрын

    I just got AlgoExpert with your coupon code, thanks for the help with your channel!

  • @vikashkumandan
    @vikashkumandan4 жыл бұрын

    You can modify the input to satisfy the O(1) space complexity. I also modified the input string by removing the necessary characters and compared them. But even better solution i found in submissions after mine was accepted was using greedy approach. You just traverse through the backspaced characters and comparing only the relevant part at each recursion.

  • @Amrable
    @Amrable4 жыл бұрын

    I like the fact that even if you are with excellent knowledge and skills you might still stuck at some point, when i do stuck at relatively easy problems i get sad tbh but this video motivated me, anyways i can’t wait for the face reveal 🙈🙈🙈

  • @fuadalhasan1784
    @fuadalhasan17844 жыл бұрын

    Yes.. I wait for your 100k... And advance congratulations for 100k 👏👏👏👏

  • @uthamkanth2505

    @uthamkanth2505

    4 жыл бұрын

    Fuad Al Hasan The concept is very well explained in this video infact i have my channel which has similar content.pls check, subscribe and show me your support if u like them and give me u r feedback in comment section.thank you:)

  • @aayushsheth915
    @aayushsheth9154 жыл бұрын

    I get so excited when I see a new errichto video!!! I love him so much lol

  • @kitaMyWifi
    @kitaMyWifi4 жыл бұрын

    I just used while(s.size() > len) { s.pop_back(); } in the ending of the remove function to handle the remaining characters.

  • @besto5448
    @besto54484 жыл бұрын

    Great video, Can you please tell what device/tablet and application you use for the sketching part while explaining?

  • @kavitaupadhyaya2870
    @kavitaupadhyaya28704 жыл бұрын

    I used two stack . If I encounter a character then push it into the stack and if I encounter # then simply continue. Did it for both the strings and then compared both of them.

  • @codeWithBatta
    @codeWithBatta4 жыл бұрын

    hey bro, can you help me with a problem? we are given n points we find manhatten distance between each pair. we are supposed to find the kth one.

  • @welldone3806
    @welldone38064 жыл бұрын

    Just iterate backward and keep count of # if count of #>0 then add character else continue repeat it for other string then compare at last

  • @ZaheerAbbas.
    @ZaheerAbbas.4 жыл бұрын

    @Errichto bro I am a beginner in programming. Can you please share your journey how you became good at this competitive programming for ex: books you read, resources you used etc. Please make a video about how you started to learn so that I can take the path that you have gone through. Please make this video.

  • @shubhamqweasd
    @shubhamqweasd4 жыл бұрын

    Can we use Rolling-Hash technique here for O(1) space, we can modify hash for each backspace by traversing back, and we will at most traverse each element twice.

  • @lisztk1928
    @lisztk19284 жыл бұрын

    Thanks again for this video! Can you confirm my thought? You wanted to get rid of the string creation because the size of that string increases as the input gets bigger and so that's a O(N) complexity, right? Thanks.

  • 4 жыл бұрын

    Hi @Errichto, which stopwatch do you use? Thanks!

  • @salman-sb8yq
    @salman-sb8yq4 жыл бұрын

    Can we do it using stringbuffer where we can delete #character and a character before it using deleteAtchar method while wtraversing the entire string .if #character is the first character in the string S and T then just skit that iteration. At the end we can check ur the two modified string buffer using equal method and returning the same

  • @secretmystery8305
    @secretmystery83054 жыл бұрын

    Nic brother. I am learning to c first then i am going to c++ and then c#.Is thic plan nice or ok for me at first.

  • @djf1513
    @djf15134 жыл бұрын

    for some problems the solution button in the top right corner is not locked and it has some really good explanations

  • @360Anurag

    @360Anurag

    4 жыл бұрын

    Its locked only when the question is from premium content.

  • @anirudh247
    @anirudh2474 жыл бұрын

    There is a function in C++ str.erase(index,no_of_characters); when you do this, it will erase the mentioned number of characters starting from that index. So I did str.erase(i-1,2) whenever I find str[i] =='#' And then i=i-2 because the next two characters index will in place of the removed ones. And Can't wait for the Face Reveal..although I know how you look! You really deserve more subscribers.

  • @manishbaghel3291

    @manishbaghel3291

    4 жыл бұрын

    Yupp it was quite easy to write this way

  • @manishbaghel3291

    @manishbaghel3291

    4 жыл бұрын

    ​@@procoder6079 No the challenge was to do it in O(N ) time and O(1) space complexity and there was no such restriction for modifying the string.

  • @manishbaghel3291

    @manishbaghel3291

    4 жыл бұрын

    @@procoder6079 ohh....yeah my bad in that case I guess traversing in reverse order is the only solution

  • @RajatSingh-dg8ov

    @RajatSingh-dg8ov

    4 жыл бұрын

    Modified the string leetcode.com/problems/backspace-string-compare/discuss/572179/Easily-explained-and-0-ms-faster-than-100.00-of-C%2B%2B-submissions

  • @oisincarroll1171

    @oisincarroll1171

    4 жыл бұрын

    std.erase is O(N), so your program is now O(N^2) though

  • @aarushi6601
    @aarushi66013 жыл бұрын

    why does if (ch==' ') give me an empty character constant if for example i replace hash with a space?? can anyone help please.

  • @shivammhaskar421
    @shivammhaskar4214 жыл бұрын

    I modified the original string. 1) I ran a while loop till string is empty or i

  • @aayushsheth915
    @aayushsheth9154 жыл бұрын

    why don't you just use .pop_back() for the modified solution. does that increase the memory?

  • @MrMatharu9
    @MrMatharu94 жыл бұрын

    I have been shouting - DO IT IN REVERSE lol

  • @franciscov511
    @franciscov5112 жыл бұрын

    I was given this problem in a Microsoft onsite interview, first I was very happy since I proposed a stack solution in 10 seconds, however my interviewer told me to focus on O(1) approach, I struggled during the 40 min interview but I was able to find the solution by iterating backwards, however I was not able to complete my code :( , after checking realized this LC problems is marked as easy,

  • @FBIhjmeric
    @FBIhjmeric4 жыл бұрын

    Hi, what's the timer plugin you were using? and what's the OS? Thanks.

  • @de_vamp

    @de_vamp

    4 жыл бұрын

    It's just cropped google stopwatch.

  • @manassinha4
    @manassinha44 жыл бұрын

    "Know my identity and so on" ... LOL

  • @sadhunarun7430
    @sadhunarun74304 жыл бұрын

    i used stack to solve this problem like push all the characters of the string . if we encounter a '#' then we pop the previous element.

  • @gitithkavitha8686

    @gitithkavitha8686

    4 жыл бұрын

    But then space isn’t O(1)

  • @ollpu

    @ollpu

    4 жыл бұрын

    That's exactly the same as his first solution. Strings are like vectors are like stacks in C++.

  • @siddharthmohanty7106
    @siddharthmohanty71064 жыл бұрын

    I used a stack, although I feel that having a knack of solving questions using 2 pointer method is really useful

  • @doluadao1995

    @doluadao1995

    4 жыл бұрын

    Well, you can use string as stack. It has pop() == pop_back() and push = push_back(). At the end you don't need to convert your stack to string.

  • @manavmohata1240

    @manavmohata1240

    4 жыл бұрын

    @@doluadao1995 you can just have 2 stacks and sompare them without converting them to strings

  • @manavmohata1240

    @manavmohata1240

    4 жыл бұрын

    @@doluadao1995 you can just have 2 stacks and compare them without converting them to strings

  • @kezhixiong8104
    @kezhixiong81044 жыл бұрын

    can't believe this is just a easy question

  • @ljlkkubsdjbs
    @ljlkkubsdjbs4 жыл бұрын

    What's the app you use for the countdown clock? Is there an alternative for it in windows? :) Thanks for the videos Errichto!

  • @Errichto

    @Errichto

    4 жыл бұрын

    It's just cropped google stopwatch.

  • @ialpha6431
    @ialpha64314 жыл бұрын

    No video, what did you do to your head ?

  • @jacobdomagala
    @jacobdomagala4 жыл бұрын

    6:57 Here if you used 0x00 instead of '#' and for string comparison used strcmp if would've worked

  • @maithreyans7484
    @maithreyans74844 жыл бұрын

    Why aren't you participating in codejam round 1-A?

  • @simplecop123
    @simplecop1234 жыл бұрын

    Don't be insecure because of the hair.. We all are here for your teachings:) please do videos as usual.

  • @avnish21kashyap
    @avnish21kashyap4 жыл бұрын

    we want to see your new hair look.

  • @williamwambua7710
    @williamwambua77104 жыл бұрын

    Errichto...why do you like using the OOP format when programming?

  • @uthamkanth2505

    @uthamkanth2505

    4 жыл бұрын

    William Tubbs The concept is very well explained in this video infact i have my channel which has similar content.pls check, subscribe and show me your support if u like them and give me u r feedback in comment section.thank you:)

  • @Aditya-us5gj
    @Aditya-us5gj4 жыл бұрын

    This question took my 4 long hours !! Yet I was unable to pass one category of test cases. One more thing, in java, if I use StringBuffer( to convert my string to StringBuffer) to solve this, will it be treated as O(n) space ?

  • @arinroday302

    @arinroday302

    4 жыл бұрын

    You crazy bro. It's quite easy solution. Another way would be to iterate backwards from both Strings and skip a character if we reach a hash

  • @ishaangupta4125

    @ishaangupta4125

    4 жыл бұрын

    It'll be O(n) space. Using a pointer approach would solve it in constant space

  • @ishaangupta4125

    @ishaangupta4125

    4 жыл бұрын

    It'll be O(n) space. Using a pointer approach would solve it in constant space

  • @tkctko

    @tkctko

    4 жыл бұрын

    StringBuffer creates another instance, which needs O(n) memory space. By the way, StringBuilder is faster than StringBuffer unless multi-thread is used.

  • @viraj_singh

    @viraj_singh

    4 жыл бұрын

    Also, StringBuffer is faster than StringBuilder as StringBuffer is not thread safe

  • @puedoamarte
    @puedoamarte4 жыл бұрын

    man i have never see this guy before, guy please sup :)

  • @dr.darkfurygaming9174
    @dr.darkfurygaming91744 жыл бұрын

    I use Stack technique for it

  • @BedoEbied
    @BedoEbied4 жыл бұрын

    There is no eye contact that's so bad!

  • @AllmohtarifeBlogspot
    @AllmohtarifeBlogspot4 жыл бұрын

    is it even possible? I did the same O(1) solution under 5 min

  • @charchitsharma8902
    @charchitsharma89024 жыл бұрын

    @errichto It seems you are really scared of your "head" space!

  • @TwoTeaTee
    @TwoTeaTee4 жыл бұрын

    Till then, hair will be back.

  • @jay-rathod-01
    @jay-rathod-014 жыл бұрын

    🤟

  • @SpaceTimeBeing_
    @SpaceTimeBeing_4 жыл бұрын

    Shaved my head and got a mohawk, show that shaved head to the world!

  • @abe10
    @abe104 жыл бұрын

    Was the haircut that bad 😆😂

  • @manmeetsingh1194
    @manmeetsingh11944 жыл бұрын

    At every accepted submission can you just give a dry run of the written code and explain each line of code by taking the example input?

  • @josephwong2832
    @josephwong28324 жыл бұрын

    I love how your avatar is sideways bro

  • @narayanbhat3279
    @narayanbhat32794 жыл бұрын

    One approach would be to go from last

  • @uthamkanth2505

    @uthamkanth2505

    4 жыл бұрын

    Narayan Bhat The concept is very well explained in this video infact i have my channel which has similar content.pls check, subscribe and show me your support if u like them and give me u r feedback in comment section.thank you:)

  • @jokerm0
    @jokerm03 жыл бұрын

    This just demonstrates that Errichto is human :p

  • @hellowill
    @hellowill4 жыл бұрын

    This problem was pretty hard (for an easy lol). I got the going through in reverse but had the issue where I was backspacing over backspace characters (e.g. abc#d##).

  • @ivanp4740

    @ivanp4740

    4 жыл бұрын

    Haha, no it isn't )) I guess solving it with O(N) space it's really easy. So basic problem is easy O(N) it's just follow up, not the one you supposed to do as basic, so it shouldn't be an easy. I guess follow up is (medium-hard)

  • @hellowill

    @hellowill

    4 жыл бұрын

    @@ivanp4740 yes the O(1) space

  • @abdelrahmanadel8998
    @abdelrahmanadel89984 жыл бұрын

    U can modify string they want from u don't use extra space

  • @vijayanantharaman
    @vijayanantharaman4 жыл бұрын

    You can maybe use a picture of the teddy bear until 100,000 subscribers

  • @aabhassaxena2490
    @aabhassaxena24904 жыл бұрын

    Without changing the input: Solution: We can use 2 pointers each on both strings and start from the end of strings In a loop We compare characters if they are not # else we ignore as many characters as many # we encounter in each string Eventually if any string is traversed then we check that the other string will have any characters after removal of # or not

  • @iitnakanpur..
    @iitnakanpur..4 жыл бұрын

    You definitely shaved yourself😂😂😂

  • @Shubham-ny2ce
    @Shubham-ny2ce4 жыл бұрын

    face reveal? who don't you? ....... your work describes you..

  • @andreykarayvansky9549
    @andreykarayvansky95494 жыл бұрын

    Haircut went wrong? :-D

  • @Diguinhoooo1
    @Diguinhoooo14 жыл бұрын

    If u made a udemy course teaching essentials i would by it 10x

  • @NotFound-hy7qb
    @NotFound-hy7qb4 жыл бұрын

    It took me a lot of time finally i used stack edit:- Your Channel logo already reveals your face lol

  • @kuldeepsingh-gi6en
    @kuldeepsingh-gi6en4 жыл бұрын

    Face reveal 😂😂😂😂 bro u are too gud.

  • @dr.darkfurygaming9174
    @dr.darkfurygaming91744 жыл бұрын

    Hey I'm your daily viewer atleast you give me heart 😇😇

  • @deviprasad4535
    @deviprasad45354 жыл бұрын

    You can check the solution after submitting the answer. Its on the right hand side top

  • @thedevhassan
    @thedevhassan4 жыл бұрын

    Haha your profile pic!!!! Revealed😍😍😍😍

  • @shashanktiwari4442
    @shashanktiwari44424 жыл бұрын

    In the codejam round 1 we need screencast with face pls😂😁

  • @0xedb
    @0xedb4 жыл бұрын

    face reveal!!!!!!!! let's go

  • @AlexSav
    @AlexSav4 жыл бұрын

    Haircut problems?

  • @gladwinrojer273
    @gladwinrojer2734 жыл бұрын

    Did you just messed up your hair??😂😂😂

  • @ronaldabellano5643
    @ronaldabellano56434 жыл бұрын

    How is this problem tagged as easy xD.

  • @charan775
    @charan7754 жыл бұрын

    really good problem if can't modify the strings

  • @almuhimen8023
    @almuhimen80234 жыл бұрын

    You sounds kinda different today. Hope everything is fine.

  • @Errichto

    @Errichto

    4 жыл бұрын

    Maybe some subconscious thing like I talk louder when the camera is on :D or maybe this problem made me sad :D

  • @HridayGajulapalli
    @HridayGajulapalli4 жыл бұрын

    What if the haircut is a diversion and the real issue is the disappearance of teddy 🤔🤔🤔

  • @saadaq2005
    @saadaq20054 жыл бұрын

    are you self taught programmer or school?

  • @angiras07
    @angiras074 жыл бұрын

    Why did you mess with your hair:(

  • @abhishek_k_jha
    @abhishek_k_jha4 жыл бұрын

    So you are really human..😳

  • @ianpan0102
    @ianpan01024 жыл бұрын

    Here's how I solved mine by going through the string backwards: void process(std::string& s) { int n = s.length(); int skip = 0, actual = 0; for (int i = n - 1; i >= 0; --i) { if (s[i] == '#') { skip++; } else { if (skip == 0) { s[n - 1 - actual] = s[i]; actual++; } skip = std::max(0, skip - 1); } } s = s.substr(n - actual, actual); } bool backspaceCompare(std::string s, std::string t) { process(s); process(t); return s == t; }

  • @ianpan0102

    @ianpan0102

    4 жыл бұрын

    Alternatively: void process(std::string& s) { int actual = 0; for (const auto& ch : s) { if (ch == '#') { actual = std::max(0, actual - 1); } else { s[actual] = ch; actual++; } } s = s.substr(0, actual); } bool backspaceCompare(std::string s, std::string t) { process(s); process(t); return s == t; }

  • @0x6e95
    @0x6e954 жыл бұрын

    rip hair

  • @shreyashjoshi4188
    @shreyashjoshi41884 жыл бұрын

    i did the problem by implementing stack.

  • @saurabh945644

    @saurabh945644

    4 жыл бұрын

    That is not order 1 space.

  • @shashanktiwari4442

    @shashanktiwari4442

    4 жыл бұрын

    Well thats the worst solution u can have for this problem 😂

  • @RajatSingh-dg8ov
    @RajatSingh-dg8ov4 жыл бұрын

    I modified the string and explained that here. leetcode.com/problems/backspace-string-compare/discuss/572179/Easily-explained-and-0-ms-faster-than-100.00-of-C%2B%2B-submissions

  • @ezdp
    @ezdp4 жыл бұрын

    hard? the O(1) solution was the natural solution

  • @andreykarayvansky9549
    @andreykarayvansky95494 жыл бұрын

    My O(N), O(1) java solution paste.ofcode.org/yrbdPtrys2hcXURHpasnuP

  • @user-mr-m12312
    @user-mr-m123124 жыл бұрын

    well something goes wrong with shaving xd

  • @Blith8690
    @Blith86904 жыл бұрын

    Hair reveal tommorow

  • @ArabianKnight63
    @ArabianKnight634 жыл бұрын

    We already know what u look like

  • @MiketheCoder
    @MiketheCoder4 жыл бұрын

    Face review at 100k.......................

  • @md.nafisurrahman6443
    @md.nafisurrahman64434 жыл бұрын

    1st comment

  • @classcure9769

    @classcure9769

    4 жыл бұрын

    so wht

  • @royplays9218
    @royplays92184 жыл бұрын

    subscribe to channel plsss...best line xD

  • @uthamkanth2505

    @uthamkanth2505

    4 жыл бұрын

    d0ccy The concept is very well explained in this video infact i have my channel which has similar content.pls check, subscribe and show me your support if u like them and give me u r feedback in comment section.thank you:)

  • @bl1nd177
    @bl1nd1774 жыл бұрын

    You shaved , didn't you? and now you are too embarrassed

  • @pskd73
    @pskd734 жыл бұрын

    This is my version github.com/pskd73/leetcode/blob/master/april_challange/p9.py

  • @dr.darkfurygaming9174
    @dr.darkfurygaming91744 жыл бұрын

    Hey I'm your daily viewer atleast you should give me heart 😇😇

  • @ashishverma3927
    @ashishverma39274 жыл бұрын

    public bool BackspaceCompare(string S, string T) { while (S.Contains("#")) { if (S.IndexOf("#") == 0) { S = S.Remove(S.IndexOf("#"), 1); } else { S = S.Remove(S.IndexOf("#") - 1, 2); } } while (T.Contains("#")) { if (T.IndexOf("#") == 0) { T = T.Remove(T.IndexOf("#"), 1); } else { T = T.Remove(T.IndexOf("#") - 1, 2); } } if(S == T) { return true; } return false; }