Coding Interview Club

Prepare for coding interviews in simple and structured steps

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /home/hearti37/public_html/codinginterviewclub/includes/menu.inc).

Important Problems on Strings and Arrays

Problem: 
  1. Write an algorithm to reverse a string.
    1. Assumptions
      1. You cannot use any library functions.
      2. You may use charAt (if needed.)
  2. Write an algorithm to find out if a string has all unique characters.
    1. Assumptions
      1. You cannot use additional data structures.
    2. References
      1. Forum topic: http://www.javajee.com/forum-topic/find-out-if-a-string-has-all-unique-c...
  3. Given two strings, write an algorithm to find if one string is a permutation of the other.
    1. Definitions
      1. permutation (or anagram) denote two strings that have same characters (with same numbers), but in different order. 
    2. Example 
      1. LISTEN and SILENT (have same characters, but in different order).
  4. Write an algorithm for string compression using counts of repeated characters
    1. Example 
      1. aaaaarrrrbbb will become a5r4b3
    2. Assumptions
      1. if the new compressed string is is bigger than the original string, return original string.
  5. Write an algorithm to find if one word is a substring of other.
    1. Example:
      1. bcd is a substring of abcde
      2. def is not a substring of abcde
    2. Assumptions
      1. You should not use any Java library functions such as contains, but may use charAt alone (if needed).
  6. Using the above algorithm alone (isSubstring), find if one string is a rotation of other.
    1. Example
      1. datastructures is a rotation of astructuresdat.
      2. cdeab is a rotation of abcde
      3. cdaeb is not a rotation of abcde.
Solution: 

Refer to individual problems under corresponding problem category for solutions.

Back to Top