Ad
Code
Diff
  • function removeEveryThird(str) 
    {
     var string str = "hello world";
      var int index = 3;
     var System.out.println("Original String = " + str);
     var StringBuffer string = new StringBuffer(str);
      System.out.println("Modified String = " + string);
      return 'heloword';
    }
    • function removeEveryThird(str) {
    • // Remove the third character from every work in the string
    • // using a zero based index
    • function removeEveryThird(str)
    • {
    • var string str = "hello world";
    • var int index = 3;
    • var System.out.println("Original String = " + str);
    • var StringBuffer string = new StringBuffer(str);
    • System.out.println("Modified String = " + string);
    • return 'heloword';
    • }
Code
Diff
  • public class Kata {
      public static boolean[] populateBathroom(boolean[] urinals, int numOfPeople) {
        return new boolean[] {true, false, true};
      }
    }
    • public class Kata {
    • public static boolean[] populateBathroom(boolean[] urinals, int numOfPeople) {
    • // Implement the urinal problem, described as "given x number of people walking
    • // into a bathroom that contains y number of urinals, describe the optimate
    • // placement of people so that none is standing next to the other"
    • // In this case, the urinals are represented by a boolean array with
    • // true representing a person at a urinal, and false meaning the urinal is empty
    • return new boolean[] {true, false, true};
    • }
    • }
Code
Diff
  • import java.util.Arrays;
    
    }public class MaxOccurence {
        public static void main(String[] args) {
            int[] intArray = {3, 5, 8, -1, 2, 5};
    
            int maxOccur = intArray[0];
    
            for (int j : intArray) {
                if (j > maxNum)
                    maxNum = j;
            }
            System.out.println("Maximum Occurence = " + maxOccur);
        }
    }
    • import java.util.Arrays;
    • class MaxOccurence {
    • }public class MaxOccurence {
    • public static void main(String[] args) {
    • int[] intArray = {3, 5, 8, -1, 2, 5};
    • public static int findMax(int[] nums) {
    • int maxOccur = intArray[0];
    • return 5;
    • }
    • for (int j : intArray) {
    • if (j > maxNum)
    • maxNum = j;
    • }
    • System.out.println("Maximum Occurence = " + maxOccur);
    • }
    • }