allcoding1
27.7K subscribers
2.2K photos
2 videos
77 files
852 links
Download Telegram
👍2
You are give a list Integers, and your task is


Python 3
👍1
Python 3
👍1
Python 3
👍2
C++
👍2
#include <iostream>
#include <vector>

using namespace std;

long makePowerNondecreasing(vector<int>& power) {
    int n = power.size();
    long adjustments = 0;

    for (int i = 1; i < n; ++i) {
        if (power[i] < power[i - 1]) {
            adjustments += power[i - 1] - power[i];
        }
    }

    return adjustments;
}

Amazon

Telegram:- @allcoding1
👍1
👍1
allcoding1
Photo
#include <iostream>
#include <vector>
using namespace std;

class SinglyLinkedListNode {
public:
    string data;
    SinglyLinkedListNode* next;

    SinglyLinkedListNode(string value) {
        data = value;
        next = nullptr;
    }
};

SinglyLinkedListNode* getShoppingCart(SinglyLinkedListNode* head, vector<vector<string>> queries) {
    for (auto& query : queries) {
        string action = query[0];
        string item_name = query[1];

        if (action == "PUSH_HEAD") {
            SinglyLinkedListNode* new_node = new SinglyLinkedListNode(item_name);
            new_node->next = head;
            head = new_node;
        } else if (action == "PUSH_TAIL") {
            SinglyLinkedListNode* new_node = new SinglyLinkedListNode(item_name);
            if (head == nullptr) {
                head = new_node;
            } else {
                SinglyLinkedListNode* current = head;
                while (current->next != nullptr) {
                    current = current->next;
                }
                current->next = new_node;
            }
        } else if (action == "POP_HEAD") {
            if (head != nullptr) {
                SinglyLinkedListNode* temp = head;
                head = head->next;
                delete temp;
            }
        }
    }

    return head;
}

Amazon
👍6🔥1
🎯OLA is hiring for Software Developer Intern
Stipend: ₹ 30k - ₹ 50k

Apply Now:- https://docs.google.com/forms/d/e/1FAIpQLSfuOSPDwkjNlXkpo4zA9_GACQxwr3lMae2YFFu6L0-6irBF4Q/viewform
👍2