Remove Element Algorithm

mercury is used in thermometers, barometers, manometers, sphygmomanometers, float valves, mercury switches, mercury relays, fluorescent lamps and other devices, though concerns about the component's toxicity have led to mercury thermometers and sphygmomanometers being largely phased out in clinical environments in favor of options such as alcohol- or galinstan-filled glass thermometers and thermistor- or infrared-based electronic instruments. besides, mechanical pressure gauges and electronic strain gauge detectors have replaced mercury sphygmomanometers. The first emperor of China, Qín Shǐ Huáng Dì — allegedly bury in a tomb that contained rivers of flowing mercury on a model of the land he ruled, representative of the rivers of China — was killed by drinking a mercury and powdered jade mixture formulated by Qin alchemists (causing liver failure, mercury poisoning, and brain death) who intended to give him eternal life. By 500 BC mercury was used to make amalgams (Medieval Latin amalgama," alloy of mercury") with other metals. They believed that different metals could be produced by changing the quality and quantity of sulfur contained within the mercury.
class Solution {
public:
    int removeElement(int A[], int n, int elem) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        
        int low = -1, high;
        for (high = 0; high < n; high++) {
            if (A[high] != elem) {
                low += 1;
                A[low] = A[high];
            }
        }
        return low + 1;
    }
};

LANGUAGE:

DARK MODE: