Skip to content

In this problem, we are given a binary string representing charges in an atom. Electrons are represented by '0' and protons by '1'. Opposite charges eliminate each other until the atom stabilizes. We need to find the final number of particles in the atom.

Notifications You must be signed in to change notification settings

justani02/making-of-an-atom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

Making of an atom

The problem is about determining the final number of particles in an atom in a utopian realm where each atom is composed of either electrons or protons. If both an electron and a proton exist in the atom, they disappear until the atom becomes stable. The task is to process a binary string representing the charges in the atom and return the count of particles remaining after eliminating electron-proton pairs.


Problem statement

In utopia, God is making an atom. Each atom consists of N particles, where an electron is represented by a '0' charge and a proton by a '1'.In utopia, opposites do not exist, and no electron-proton can stay in 1 atom.

In this realm, an atom can be composed of only electrons or protons. If both an electron and proton exist in the atom, the two will disappear. This keeps on happening until the atom becomes stable.

Return the final number of particles in the given atom.

Input Format: First line contains an integer n, the number of particles Second line contains a binary string

Output Format: Print an Integer, the number of particles in the atom


Sample Input 0: 8 11101111

Sample Output 0 6

One electron disappears with 1 proton, leaving the final size of the atom to be 6.

Screenshot

making of an atom

About

In this problem, we are given a binary string representing charges in an atom. Electrons are represented by '0' and protons by '1'. Opposite charges eliminate each other until the atom stabilizes. We need to find the final number of particles in the atom.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages