Revision: 8806
Updated Code
at October 9, 2008 03:05 by jaircazarin
Updated Code
#include<stdio.h> int deleteRepeatedNumbers(int list[], int size) { if(size < 1) return 0; int newLength = 1; for(int i = 1; i < size; i++) if(list[i-1] != list[i]) list[newLength++] = list[i]; return newLength; } int main() { int sortedArray[] = {1, 1, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6 ,6 ,6, 11}; printf("%d", deleteRepeatedNumbers(sortedArray, 15)); return 0; }
Revision: 8805
Updated Code
at October 9, 2008 03:04 by jaircazarin
Updated Code
#include<stdio.h> int deleteRepeatedNumbers(int list[], int size) { if(size < 1) return 0; int newLength = 1; for(int i = 1; i < size; i++) if(list[i-1] != list[i]) list[newIndex++] = list[i]; return newLength; } int main() { int sortedArray[] = {1, 1, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6 ,6 ,6, 11}; printf("%d", deleteRepeatedNumbers(sortedArray, 15)); return 0; }
Revision: 8804
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 9, 2008 03:02 by jaircazarin
Initial Code
#include<stdio.h> int deleteRepeatedNumbers(int list[], int size) { int newLength = 1; for(int i = 1; i < size; i++) if(list[i-1] != list[i]) list[newIndex++] = list[i]; return newLength; } int main() { int sortedArray[] = {1, 1, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6 ,6 ,6, 11}; printf("%d", deleteRepeatedNumbers(sortedArray, 15)); return 0; }
Initial URL
Initial Description
Given a sorted array return the new length of the array with no-repeated numbers. Interesting test cases: * All the same number * No repetitions * Empty array * Negative size * One element
Initial Title
Delete Repeated Numbers
Initial Tags
Initial Language
C