Tag Archives: String

Java String Array Iterator Example

Problem Given the signature of the Java method below public static Iterator iterateStrings(String… strings) Provide implementation that iterates through each string in the order that they are provided but it skips null values Solution We implement the Iterable interface. We …

Read more »

Dynamic Programming Edit Distance

Edit Distance or Levenshtein Distance Welcome! This is part eight in a series of articles on Dynamic Programming. You can start at the beginning of this series if you wish by clicking here. Today we are going to talk about …

Read more »

Lexicographic Order in Java

Lexicographic Order Problem Write java method to compare two strings lexicographically. The method should return 0 if the two strings are Lexicographically equal. It should return 1 if the first string comes before the second string in the dictionary. It …

Read more »

Java Replace String Function

Problem Write a Java method to replace a sub string in a given text with another string of the same size Solution Loop through the text character by character. Starting at the current character loop a number of times equal …

Read more »

Copy String C++

Problem Write a C++ function to copy an existing string. Do not use built in functions. Solution This is a straight forward question and to my surprise I was asked this question in a site interview. If you are not …

Read more »

Reverse String Word by Word

Problem Write a program to reverse an English sentence word by word not character by character. For example if the sentence is “I love Pizza so much” the program should print “much so Pizza love I” Solution One solution is …

Read more »

Read Binary File in Perl

Problem Given the path to a directory. Write a Perl script to print the average time to open and read all files in that directory. The files should be read in blocks of 64 KB Solution This is straightforward problem …

Read more »

Page 1 of 41234