Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
674 views
in Online Assessments by Expert (46,090 points) | 674 views

3 Answers

0 like 0 dislike
Best answer

Was given 2 questions and 60 mins to submit:

 

  1.  

    image

     

  2.  

    https://leetcode.com/problems/count-good-nodes-in-binary-tree

by Expert (46,090 points)
0 like 0 dislike

First question was asked in a contest recently.
It can be done easily
problem link: https://leetcode.com/problems/remove-digit-from-number-to-maximize-result/

by Expert (46,090 points)
0 like 0 dislike

C++ Solution

 

class Solution
{

public:
    int removeOneFive(int N)
    {
        string str = to_string(N);
        int mx = -999999;
        for (int i = 0; i < str.length(); ++i)
        {
            if (str[i] == '5')
            {
                auto n = str.substr(0, i) + str.substr(i + 1);
                mx = max(mx, stoi(n));
            }
        }
        return mx;
    }
};
by Expert (46,090 points)