@@ -0,0 +1,1154 @@
+package interviewquestions.java;%0A%0A/**%0A * Given a string 'S' and a character 't'. Print out the position of the rightmost%0A * occurrence of 't' (case matters) in 'S' or -1 if there is none.%0A */%0Apublic class RightMostCharacter %7B%0A  public static int rightmost(String string, Character ch) %7B%0A    for (int idx = string.length() - 1; idx %3E= 0; --idx) %7B%0A      if (string.charAt(idx) == ch) return idx;%0A    %7D%0A    return -1;%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    test(rightmost(%22Hello World%22, 'r') == 8);%0A    test(rightmost(%22Hello World%22, 'd') == 10);%0A    test(rightmost(%22Hello WOrld%22, 'o') == 4);%0A    test(rightmost(%22Hello WOrld%22, 'O') == 7);%0A    test(rightmost(%22aaaaaaaaaaa%22, 'a') == 10);%0A    test(rightmost(%22%22, 'a') == -1);%0A    test(rightmost(%22How to learn to Cook%22, 'C') == 16);%0A    test(rightmost(%22What is your name%22, 'm') == 15);%0A    test(rightmost(%22lKHFLOpCmu0bxE0AooKQ8gYcrvf7Go22pMVKjFCc7DU9qIpcd55 Px00SdUCV4fzSq%22, 'W') == -1);%0A  %7D%0A%0A  public static void test(boolean condition) %7B%0A    // assertions are disabled by default in java, mimic their behaviour here%0A    if (!condition) %7B%0A      throw new AssertionError(%22invalid test%22);%0A    %7D%0A  %7D%0A%7D%0A

find the rightmost occurrence of a character