Write a program to reverse a String or find duplicate characters in an array without using built-in library functions.