Minimum distance between chars

Given a String, start char and end char, find the minimum distance between these two chars. If one of the strings is null or if the characters are not present we should return 0 Input 1: String: "hello world" Char1: ' ' Char 2: 'o' Output: 2 Input 2: String: "can I go to zoo" Char1: 'o' Char 2: 'o' Output: 1 public class Answer implements MinDistanceBetweenCharsInterface { @Override public int MinDistanceBetweenChars(String str, char startChar, char endChar) { // WRITE YOUR CODE HERE return 0; } public static void main(String [] args) { // write code here to test } }

Answer

No comments:

Post a Comment