Understand ground and ceramic non polarized capacitor
The basic idea is very simple: we're going to see how long how long it takes to charge up a fixed capacitor through a resistance whose value changes with incident light or temperature.


C will be discharged initially.
When the charging pin is switched high C will charge at a rate determined by RC (where R is the sum of R1 and the photoresistor). After RC s it will have charged to 63% of the supply voltage.
The discharge pin, meanwhile, is configured as an input and is monitoring the voltage on C. (R3 doesn't affect this because as an input the pin is drawing negligible current.) 
The logic 1 threshold voltage of the input pin will be about 2/3 supply and this fits nicely with our RC time constant at 63%. When the pin detects the '1' the measurement counter can now stop.
At some stage we'll need to reset the circuit and discharge C. To do this we'll reconfigure the discharge pin as an output, switch it low (0 V) and give enough time for C1 to discharge through R3. R3 limits the current to a safe value - 5 mA max on a 5 V supply - so that we don't damage the GPIO. We would need to allow 5RC (where R is 1k this time) to discharge by 99% from the peak voltage.
Once discharge is complete we can disable the output, switch it back to an input and start all over again.



  I do not know if the current can charge (from the ground) non-polarized capacitors. 


They're probably recommending non-polarized capacitors as these can be more stable and tighter tolerance than electrolytics. Also, electrolytics don't come in &lt; 1 &mu;F usually.


  I also have a negative voltage on OUT (GPIO18) when I simulate GPIO states ...


You should never see negative voltages with this circuit. (GND is zero, not negative.)


  ... and I do not understand why the voltage is negative when I unload and read the value for this pin and not for OUT (GPIO04).


This part isn't clear.

Let's look at a quick simulation. (You can copy it into your question to try it out in CircuitLab's simulator.)







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. A simplified schematic. Here Q1 is simulating the discharge function.



Figure 2. Note the slow charge and the rapid discharge of the capacitor.

Note that in Figure 2 that the capacitor never discharges fully. This is because the GPIO_OUT is always at 5 V in my simulation so it is charging C1 while DISCH is discharging it.