Apple - How can I merge primary APFS partition with other empty APFS partition?

If anyone still looking for answer.

Step 1: Delete the container

sudo diskutil apfs deleteContainer disk0s3

this will change the container to Apple_HFS Untitled 98.9 GB disk0s3

Step 2: Erase the volume

sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3

Step 3: Resize the container

sudo diskutil apfs resizeContainer disk0s2 0

  1. Remove ‘Apple_KernelCoreDump’ and ‘Container disk2’.

    sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3
    sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s4
    
  2. Expand ‘Container disk1’ to fill the free space.

    sudo diskutil apfs resizeContainer disk0s2 0
    

Unfortunately, after trying all solutions I found, I had to restart my comuputer in recovery mode, and reinstall a fresh OSX. I made a Time Machine backup before doing this, and I am now running my Mac as before, but with the fully reclaimed space (500.00 GB)