You'll have to contact each school you plan on applying to about their policy as it differs... I asked UCSF about retaking a class and they said that the conditions were if I originally took it at a university and got a C- or below, I could re take it at the university and have only the second grade counted... or re-take it at a CC and average the two out.
Let me make it clear: either way, they look at all your grades. So does it doesn't really matter unless you need the better grade to make your GPA above the minimum requirement. Most schools will look at your higher grade only when making this GPA calculation. However, you rank somewhat less than those who did not repeat. Usually, applications are judged holistically in california, so this doesn't mean that you won't fair well in the admissions process if you have this repeat. However it does exist and it is negative.