import org.junit.jupiter.api.Test; class Solution { public static int similarPairs(String[] words) { int num=0; for(int i=0; i<words.length; i++){ for(int j=i+1; j<words.length; j++){ if(words[i]==words[j]) num+=1; } } return num; } }
- import org.junit.jupiter.api.Test;
- class Solution {
public int similarPairs(String[] words) {return 2;- public static int similarPairs(String[] words) {
- int num=0;
- for(int i=0; i<words.length; i++){
- for(int j=i+1; j<words.length; j++){
- if(words[i]==words[j])
- num+=1;
- }
- }
- return num;
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testSomething() { Solution aaa = new Solution(); String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; assertEquals("actual", "actual"); assertEquals(aaa.similarPairs(cars), 0); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void testSomething() {
- Solution aaa = new Solution();
- String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
- assertEquals("actual", "actual");
assertEquals(aaa.similarPairs(cars), 1);- assertEquals(aaa.similarPairs(cars), 0);
- }
- }