Sort by

recency

|

1453 Discussions

|

  • + 0 comments

    I thought some LeetCode problems were already quite counter-intuitive and frustrating. This HackerRank problem really opened my eyes, much like a guide to painting ceilings can reveal tips you never expected. I didn’t expect a problem to be designed in such a psychologically twisted way. So many traps.

  • + 0 comments

    I thought some LeetCode problems were already quite counter-intuitive and frustrating. This HackerRank problem really opened my eyes. I didn’t expect a problem to be designed in such a psychologically twisted way. So many traps.

  • + 0 comments

    Python3 Solution

    def appendAndDelete(s, t, k):
        if len(t) + len(s) <= k:
            return "Yes"
        
        while k > 0:     
            if s > t:
                s = s[:-1]
                k -= 1
            elif s == t:
                return "Yes"
            else:
                print(s)
                if s == t[:len(s)]:
                    if (k - (len(t)-len(s))) % 2 == 0 and k >= len(t)-len(s):
                        return "Yes"
                    return "No"
                else:
                    s = s[:-1]
                    k -= 1
                
        return "No"
    
  • + 0 comments

    Here is append and delete problem solution in python, java, c++, c and javascript - https://programmingoneonone.com/hackerrank-append-and-delete-problem-solution.html

  • + 0 comments

    C++

    string appendAndDelete(string s, string t, int k) {
        int same_letters = 0;
        int cnt1 = s.size();
        int cnt2 = t.size();
        int min_val = min(cnt1, cnt2);
    
        for (int i = 0; i < min_val; i++) {
            if (s[i] == t[i]) {
                same_letters++;
            } else break;
        }
    
        int amount = (cnt1 - same_letters) + (cnt2 - same_letters);
    
        if (amount == k) {
            return "Yes" ;
        } else if (amount < k) {
            if ((k - amount) % 2 == 0 || k >= cnt1 + cnt2) {
                return "Yes";
            }
        }
    
        return "No";
    }