Write an “isTwin(a, b)” method that returns true if a and b are twins and returns false if they are not. a and b are two strings

// Class de test (Main)

public class IsTwin {

    public static void main(String[] args) {

	System.out.println(Solution.isTwin("Hello", "world")); // false
	System.out.println(Solution.isTwin("acb", "bca")); // true
	System.out.println(Solution.isTwin("Lookout", "Outlook")); // true

// Class Solution 

class Solution {
    public static boolean isTwin(String a, String b) {
	    char[] first = a.toLowerCase().toCharArray();
	    char[] second = b.toLowerCase().toCharArray();
    return Arrays.equals(first, second);


Laisser un commentaire