Telemetry Packet Memory Cleanup

#include <iostream>
using namespace std;

int main() {
    int firstValue, secondValue;
    cin >> firstValue >> secondValue;

    int* packet = new int;
    *packet = firstValue; 

    delete packet;
    packet = nullptr;

    packet = new int;           
    *packet = secondValue;      

    
    cout << *packet << endl;

    delete packet;
    packet = nullptr;
    
    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

25 40

Expected Output

40