๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.7K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
def find_mvp(n, A):
    mvp = []
    max_right = A[-1]
    mvp.append(max_right)

    for i in range(n - 2, -1, -1):
        if A[i] > max_right:
            max_right = A[i]
            mvp.append(max_right)

    mvp.reverse()
    return mvp

if name == 'main':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    n = int(input().strip())
    A_count = int(input().strip())
   
    A = list(map(int, input().rstrip().split()))

    mvp = find_mvp(n, A)
   
   
    mvp_str = ' '.join(map(str, mvp))

    fptr.write(mvp_str + '\n')
    fptr.close()

Salesforce โœ…
MVP in Array
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
class Result {
public:
    static vector<string> reformatDate(vector<string> dates) {
        vector<string> outputDate;

        for (const string& tempStr : dates) {
            string formattedDate = tempStr;
            size_t pos = formattedDate.find_first_of("0123456789");
            if (pos != string::npos) {
                formattedDate = formattedDate.substr(pos);
                struct tm tempTm;
                if (strptime(formattedDate.c_str(), "%d %b %Y", &tempTm) != nullptr) {
                    int year = tempTm.tm_year + 1900;
                    if (year >= 1900 && year <= 2100) {
                        ostringstream oss;
                        oss << year << "-" << setw(2) << setfill('0') << tempTm.tm_mon + 1 << "-" << setw(2) << setfill('0') << tempTm.tm_mday;
                        outputDate.push_back(oss.str());
                    } else {
                        cout << "Year out of range" << endl;
                    }
                }
            }
        }

        return outputDate;
    }
};

int main() {
    int datesCount;
    cin >> datesCount;
    cin.ignore(numeric_limits<streamsize>::max(), '\n');

    vector<string> dates;
    for (int i = 0; i < datesCount; ++i) {
        string date;
        getline(cin, date);
        dates.push_back(date);
    }

    vector<string> result = Result::reformatDate(dates);

    for (const string& formattedDate : result) {
        cout << formattedDate << endl;
    }

    return 0;
}

Goldman Sachs โœ