public class Test4B extends Object
Constructor and Description |
---|
Test4B() |
Modifier and Type | Method and Description |
---|---|
static String |
countTo(int from,
int to)
Returns the string formed by counting starting at
from
up to and including to in increments of 1. |
static int |
findZero(List<Integer> t)
Returns the index of the element equal to zero in the
specified sorted list.
|
static void |
unique(List<String> t)
Removes all duplicated strings from a sorted list of strings
maintaining the sorted order of the strings.
|
static String |
zipper(String s,
String t)
Given two non-null strings of equal length, returns the string formed by
alternating characters from s and t.
|
public static String countTo(int from, int to)
from
up to and including to
in increments of 1. Each
number in the string is separated from the next number by a
comma and a space.
countTo(1, 1) returns the string equal to "1" countTo(5, 6) returns the string equal to "5, 6" countTo(10, 12) returns the string equal to "10, 11, 12"
from
- the number to count fromto
- the number to count topublic static String zipper(String s, String t)
zipper("", "") returns the empty string zipper("a", "1") returns the string "a1" zipper("abcd", "1234") returns the string "a1b2c3d4"
s
- a string of length nt
- a second string of length npublic static void unique(List<String> t)
t
- a sorted list of strings that the method modifies
so that it contains no duplicated strings (and the list remains in
sorted order).public static int findZero(List<Integer> t)
The computational complexity of the method is O(log n) where n is the size of the list t.
t
- a sorted list