Problem Statement
To sort your list, you decide to mark a field as the title if it satisfies at least one of the following criteria:
- It contains at least one of the following words: "the", "and", or "of".
- It contains more than 3 space-delimited words.
You figure that following these rules will sort most of your books, but you need a routine to check the rest of them manually so you can sort them yourself.
You are given a
Definition
- Class:
- SortBooks
- Method:
- checkManually
- Parameters:
- String[], String[]
- Returns:
- int[]
- Method signature:
- int[] checkManually(String[] field1, String[] field2)
- (be sure your method is public)
Notes
- When checking for "the", "and", and "of", note that they are case insensitive.Thus "the" = "tHE" = "THE", etc.
Constraints
- field1 will contain between 1 and 50 elements, inclusive.
- field2 will contain an equal number of elements as field1.
- Each element in field1 and field2 will contain between 1 and 50 characters, inclusive.
- field1 and field2 will consist only of letters ('a'-'z', 'A'-'Z') and spaces.
- field1 and field2 will have no leading or trailing spaces.
Examples
{ "J R R Tolkien", "THE Jungle BOOK" }
{ "THE HOBBIT", "RUDYARD KIPLING" }
Returns: {0 }
Both "J R R Tolkien" and "THE HOBBIT" are considered titles because "J R R Tolkien" is 4 words and "THE HOBBIT" contains "THE". Therefore it needs to be checked manually.
{ "Scaramouche", "Dan Brown", "War and Peace" }
{ "Rafael Sabatini", "The Da Vinci Code", "Leo Tolstoy" }
Returns: {0 }
The first book needs to be checked, because there is not enough information to tell which one is the title.
{ "a b c", "d e f", "ghijklmn", "opqrstuv", "w x y z", "aaa bbb ccc ddd" }
{ "AA aNd BB", "GO", "Stop the clock", "of", "pizza dinner for two", "andofthe" }
Returns: {1, 4 }
{ "Aesop", "Little Women", "Hans Christian Anderson", "The Arabian Nights", "Peter Christian Asbornsen", "Mr Poppers Penguins", "Enid Bagnold", "Miss Hickory", "Sir James Barrie", "The Wizard of OZ", "Ludwig Bemelmans", "The Five Chinese Brothers", "Edith Nesbit Bland", "The Enchanted Castle", "Edith Nesbit Bland", "Five Children and It", "Michael Bond", "The Children of Green Knowe", "James Boyd", "Caddie Woodlawn", "Walter Brooks", "The Runaway Bunny", "Margaret Wise Brown", "Big Red Barn", "Jean De Brunhoff", "Old Mother West Wind", "Frances Hodgson Burnett", "A Little Princess", "Frances Hodgson Burnett", "Mike Mulligan and His Steam Shovel", "Virginia Lee Burton", "The Enormous Egg", "Eleanor Cameron", "The Happy Orpheline", "Natalie Savage Carlson", "Through the Looking Glass", "Miguel Cervantes", "Secret of the Andes", "Beverly Cleary", "Henry Huggins", "Elizabeth Coatsworth", "The Adventures of Pinocchio", "Barbara Cooney", "The Little Lame Prince", "Paul Creswick", "The Courage of Sarah Noble", "Alice Dagliesh" }
{ "Aesops Fables", "Louisa May Alcott", "Fairy Tales", "Hans Christian Anderson", "East of the Sun and West of the Moon", "Richard and Florence Atwater", "National Velvet", "Carolyn Bailey", "Peter Pan", "Frank L Baum", "Madeline", "Claire Huchet Bishop", "The Railway Children", "Edith Nesbit Bland", "The Story of the Treasure Seekers", "Edith Nesbit Bland", "A Bear Called Paddington", "Lucy Boston", "Drums", "Carol Rylie Brink", "Freddy the Detective", "Margaret Wise Brown", "The Little Fur Family", "Moon Goodnight", "The Story of Babar", "Thornton W Burgess", "Little Lord Fauntleroy", "Frances Hodgson Burnett", "The Secret Garden", "Virginia Lee Burton", "The Little House", "Oliver Butterworth", "The Wonderful Flight to the Mushroom Planet", "Natalie Savage Carlson", "The Family Under the Bridge", "Lewis Carroll", "Don Quixote", "Ann Nolan Clark", "Beezus and Ramona", "Beverly Cleary", "The Cat Who Went to Heaven", "Carlo Collodi", "Chanticleer and the Fox", "Dinah Mulock Craik", "Robin Hood", "Alice Dagliesh", "The Bears on Hemlock Mountain" }
Returns: {0, 1, 2, 6, 7, 8, 10, 18, 19, 23, 26, 27, 36, 39, 44 }
{ "This is a test of the emergency broadcast system" }
{ "Had this been an actual emergency you would be sad" }
Returns: {0 }
{ "This Star Shall Abide" }
{ "Sylvia Louise Engdahl" }
Returns: { }
{ "Lost Horizon" }
{ "James Hilton" }
Returns: {0 }
Words in titles and/or authors may be separated by more than one space.
{ "andy rooney", "joe lofthouse", "Theodore Taylor" }
{ "love of life", "the arrest", "Softly Wandering" }
Returns: {2 }
{ "Alpha Omega", "The Watch", "Secrets", "Somebody Somewhere and Sons" }
{ "The Book", "Of Nothing", "Desires", "Crowded Streets" }
Returns: {1, 2 }
{ "Softwalker" }
{ "Winning" }
Returns: {0 }
{ "A", "B", "C", "oF", "tHe", "anD", "sOFt", "hANDy", "aTHEist" }
{ "SofT", "SandY", "BROtheR", "Often Wrong", "Theodore", "Spandex", "Look Away", "See Spot Sit", "Moving Around" }
Returns: {0, 1, 2, 6, 7, 8 }
{ "Java Two Fifth Edition" }
{ "Herbert Schildt" }
Returns: { }
{ "Georgette Heyer", "Captain Blood", "The Black Cauldron", "Michael P Kube McDowell" }
{ "The Nonesuch", "Rafael Sabatini", "Lloyd Alexander", "Star Wars Before The Storm" }
Returns: {1, 3 }
{ "Ignoring Extra Spaces", "Geena Davis" }
{ "Is very Easy to do", "Cutthroat Island" }
Returns: {1 }
{ "The Beggar Queen", "White Fang", "Jack London", "Hannas Daughters" }
{ "Lloyd Alexander", "Jack London", "The Call of the Wild", "Marianne Frederiksson" }
Returns: {1, 3 }
{ "The Great Snow", "The Green Bay Tree", "Without Armor", "The Officer Factory", "The Dark River", "Castle Garac", "The Hurricane", "Dynasty of Death", "Claudia" }
{ "Henry Morton Robinson", "Louis Bromfield", "James Hilton", "Hans Hellmut Kirst", "Nordoff and Hall", "Nicholas Monsaratt", "Nordoff and Hall", "Taylor Caldwell", "Rose Franken" }
Returns: {2, 4, 5, 6, 8 }
{ "of" }
{ "me" }
Returns: { }
{ "me" }
{ "of" }
Returns: { }
{ "and" }
{ "and" }
Returns: {0 }
{ "the" }
{ "one two three four" }
Returns: {0 }
{ "one two three four" }
{ "and" }
Returns: {0 }
{ "This and That", "What the heck", "Queen of Hearts" }
{ "Run to me", "Close your gate", "King of Spades" }
Returns: {2 }
{ "Margaret Moore", "Sharon Schulze", "Catherine Archer", "Lyn Stone", "Jacqueline Navin", "Theresa Michaels", "Millie Criswell", "Carolyn Davidson", "Mary McBride", "Judith Stacy" }
{ "A Warriors Kiss", "Lady of the Keep", "The Bride of Spring", "My Ladys Choice", "The Vikings Heart", "Once a Hero", "The Marrying Man", "Tanner Stakes his Claim", "Banderas Bride", "The Blushing Bride" }
Returns: {0, 3, 5, 8 }
{ "a" }
{ "b" }
Returns: {0 }
{ "Melody Beattie", "Vince Emery", "Jim Davis", "Rafael Sabatini" }
{ "Journey to the Heart", "How to Grow Your Business on the Internet", "Garfield Takes the Cake", "Scaramouche" }
Returns: {3 }
{ "Timothy Zahn", "Kathy Tyers", "Michael A Stackpole", "Dave Wolverton", "Timothy Zahn", "Timothy Zahn", "Kevin J Anderson", "Barbara Hambly", "Kevin J Anderson", "Kevin J Anderson", "Kevin J Anderson", "Vonda N McIntyre", "Roger McBride Allen", "Roger McBride Allen", "Roger McBride Allen" }
{ "Heir to the Empire", "The Truce at Bakura", "Rogue Squadron", "The Courtship of Princess Leia", "Dark Force Rising", "The Last Command", "Jedi Search", "Children of the Jedi", "Darksaber", "Dark Apprentice", "Champions of the Force", "The Crystal Star", "Ambush at Corellia", "Assault at Selonia", "Showdown at Centerpoint" }
Returns: {2, 4, 6, 8, 9, 12, 13, 14 }
{ "To be or not to be that is the question" }
{ "William Shakespeare" }
Returns: { }
{ "a b c d e f g h i j k l m n o p q r s t u v w x yz" }
{ "fifty length title" }
Returns: { }
{ "one two three four five six seven eight nine ten" }
{ "eleven twelve thirteen fourteen fifteen sixteen" }
Returns: {0 }
{ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y" }
{ "apple", "banana", "car", "dog", "elf", "fun", "good", "hog", "ice", "jar", "kid", "log", "man", "new", "old", "pig", "quiz", "road", "star", "top", "Uranus", "venus", "water", "xray", "zoo", "Aardvark", "Bear", "Cat", "Dog", "Exit", "Funny", "Grin", "Hurry", "Idea", "Jump", "Ka", "Lie", "Me", "No", "Oz", "Pie", "Quad", "Rust", "Star", "Tar", "Ugly", "View", "Woman", "eXodus", "Yam" }
Returns: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 }
{ "We have seen", "A lot", "of books here", "today" }
{ "We have also seen", "A lot of", "nonsense", "as well" }
Returns: {3 }
{"Aesop", "Little Women", "Hans Christian Anderson", "The Arabian Nights", "Peter Christian Asbornsen", "Mr Poppers Penguins", "Enid Bagnold", "Miss Hickory", "Sir James Barrie", "The Wizard of OZ", "Ludwig Bemelmans", "The Five Chinese Brothers", "Edith Nesbit Bland", "The Enchanted Castle", "Edith Nesbit Bland", "Five Children and It", "Michael Bond", "The Children of Green Knowe", "James Boyd", "Caddie Woodlawn", "Walter Brooks", "The Runaway Bunny", "Margaret Wise Brown", "Big Red Barn", "Jean De Brunhoff", "Old Mother West Wind", "Frances Hodgson Burnett", "A Little Princess", "Frances Hodgson Burnett", "Mike Mulligan and His Steam Shovel", "Virginia Lee Burton", "The Enormous Egg", "Eleanor Cameron", "The Happy Orpheline", "Natalie Savage Carlson", "Through the Looking Glass", "Miguel Cervantes", "Secret of the Andes", "Beverly Cleary", "Henry Huggins", "Elizabeth Coatsworth", "The Adventures of Pinocchio", "Barbara Cooney", "The Little Lame Prince", "Paul Creswick", "The Courage of Sarah Noble", "Alice Dagliesh" }
{"Aesops Fables", "Louisa May Alcott", "Fairy Tales", "Hans Christian Anderson", "East of the Sun and West of the Moon", "Richard and Florence Atwater", "National Velvet", "Carolyn Bailey", "Peter Pan", "Frank L Baum", "Madeline", "Claire Huchet Bishop", "The Railway Children", "Edith Nesbit Bland", "The Story of the Treasure Seekers", "Edith Nesbit Bland", "A Bear Called Paddington", "Lucy Boston", "Drums", "Carol Rylie Brink", "Freddy the Detective", "Margaret Wise Brown", "The Little Fur Family", "Moon Goodnight", "The Story of Babar", "Thornton W Burgess", "Little Lord Fauntleroy", "Frances Hodgson Burnett", "The Secret Garden", "Virginia Lee Burton", "The Little House", "Oliver Butterworth", "The Wonderful Flight to the Mushroom Planet", "Natalie Savage Carlson", "The Family Under the Bridge", "Lewis Carroll", "Don Quixote", "Ann Nolan Clark", "Beezus and Ramona", "Beverly Cleary", "The Cat Who Went to Heaven", "Carlo Collodi", "Chanticleer and the Fox", "Dinah Mulock Craik", "Robin Hood", "Alice Dagliesh", "The Bears on Hemlock Mountain" }
Returns: {0, 1, 2, 6, 7, 8, 10, 18, 19, 23, 26, 27, 36, 39, 44 }
{"of" }
{"test" }
Returns: { }
{"J R R Tolkien", "THE Jungle BOOK" }
{"THE HOBBIT", "OFFF LALA" }
Returns: {0 }
{"andy rooney", "joe lofthouse", "Theodore Taylor" }
{"love of life", "the arrest", "Softly Wandering" }
Returns: {2 }
{"Lost Horizon" }
{"James Hilton" }
Returns: {0 }
{"the" }
{"theof" }
Returns: { }
{"Scaramouche", "Dan Brown", "War and" }
{"Rafael Sabatini", "The Da Vinci Code", "Leo Tolstoy The" }
Returns: {0, 2 }
{"Mountain Dew is undisputed best drink" }
{"Sartak the" }
Returns: {0 }
{"of abc" }
{"or abc" }
Returns: { }
{"theMK" }
{"mk The" }
Returns: { }
{"this should be a title long" }
{"notitle" }
Returns: { }
{"J R R Tolkien", "THE Jungle BOOK" }
{"THE HOBBIT", "RUDYARAND KIPLING" }
Returns: {0 }
{"J RR Tolkien", "THE Jungle BOOK" }
{"THE", "RUDYARD KIPLING" }
Returns: { }
{"a b c" }
{"the" }
Returns: { }
{"Alexander Greand" }
{"Alexander Greand" }
Returns: {0 }
{"Aesop", "Little Women", "Hans Christian Anderson", "The Arabian Nights", "Peter Christian Asbornsen", "Mr Poppers Penguins", "Enid Bagnold", "Miss Hickory", "Sir James Barrie", "The Wizard of OZ", "Ludwig Bemelmans", "The Five Chinese Brothers", "Edith Nesbit Bland", "The Enchanted Castle", "Edith Nesbit Bland", "Five Children and It", "Michael Bond", "The Children of Green Knowe", "James Boyd", "Caddie Woodlawn", "Walter Brooks", "The Runaway Bunny", "Margaret Wise Brown", "Big Red Barn", "Jean De Brunhoff", "Old Mother West Wind", "Frances Hodgson Burnett", "A Little Princess", "Frances Hodgson Burnett", "Mike Mulligan and His Steam Shovel", "Virginia Lee Burton", "The Enormous Egg", "Eleanor Cameron", "The Happy Orpheline", "Natalie Savage Carlson", "Through the Looking Glass", "Miguel Cervantes", "Secret of the Andes", "Beverly Cleary", "Henry Huggins", "Elizabeth Coatsworth", "The Adventures of Pinocchio", "Barbara Cooney", "The Little Lame Prince", "Paul Creswick", "The Courage of Sarah Noble", "Alice Dagliesh", "Ofasd ofasdfsd" }
{"Aesops Fables", "Louisa May Alcott", "Fairy Tales", "Hans Christian Anderson", "East of the Sun and West of the Moon", "Richard and Florence Atwater", "National Velvet", "Carolyn Bailey", "Peter Pan", "Frank L Baum", "Madeline", "Claire Huchet Bishop", "The Railway Children", "Edith Nesbit Bland", "The Story of the Treasure Seekers", "Edith Nesbit Bland", "A Bear Called Paddington", "Lucy Boston", "Drums", "Carol Rylie Brink", "Freddy the Detective", "Margaret Wise Brown", "The Little Fur Family", "Moon Goodnight", "The Story of Babar", "Thornton W Burgess", "Little Lord Fauntleroy", "Frances Hodgson Burnett", "The Secret Garden", "Virginia Lee Burton", "The Little House", "Oliver Butterworth", "The Wonderful Flight to the Mushroom Planet", "Natalie Savage Carlson", "The Family Under the Bridge", "Lewis Carroll", "Don Quixote", "Ann Nolan Clark", "Beezus and Ramona", "Beverly Cleary", "The Cat Who Went to Heaven", "Carlo Collodi", "Chanticleer and the Fox", "Dinah Mulock Craik", "Robin Hood", "Alice Dagliesh", "The Bears on Hemlock Mountain", "osfadsf ofasdfsd" }
Returns: {0, 1, 2, 6, 7, 8, 10, 18, 19, 23, 26, 27, 36, 39, 44, 47 }
{"J R R Tolkien", "jungle THE" }
{"THE HOBBIT", "RUDYARD KIPLING" }
Returns: {0 }
{"ofOfF of The and", "ana makrick", "ksdljf kjsdlj kjsdf", "kfdsj la d", "df d" }
{"ofka andd", "gfdgfd fd", "sdf dsfdsf dsfds", "d d d", "andd" }
Returns: {1, 2, 3, 4 }
{"J R R Tolkien", "THE Jungle BOOK" }
{"THE HOBBIT", "OFFF LALAOF" }
Returns: {0 }
{"THE" }
{"x" }
Returns: { }
{"This is the test" }
{"The the the" }
Returns: {0 }
{"blof blof" }
{"the big mistery" }
Returns: { }
{"short" }
{"notitle" }
Returns: {0 }
{"find or" }
{"find find" }
Returns: {0 }
{"test or test", "test or aduh" }
{"test saya", "test lagi ah" }
Returns: {0, 1 }
{"an arr" }
{"is the" }
Returns: { }
{"or son" }
{"the wells" }
Returns: { }
{"aduh aduh the", "lagi lagi the", "lagi lagi of" }
{"test saya", "test lagi ah", "judul" }
Returns: { }
{"andy rooney", "joe lofthouse", "Theodore Taylor the" }
{"love of life", "ther arrest", "Softly Wandering" }
Returns: {1 }
{"THE" }
{"HI" }
Returns: { }
{"asdlfj asdf of" }
{"asdf jks" }
Returns: { }
{"he he", "he he he" }
{"he he he", "he he" }
Returns: {0, 1 }
{"ONE TWO THREE" }
{"THE TITLE" }
Returns: { }
{"J G Tolkien", "THE Jungle BOOK" }
{"THE HOBBIT", "RUDYARD KIPLING" }
Returns: { }
{"thethe ofofand of" }
{"the and theof" }
Returns: {0 }
{"Lost Horizon" }
{"James Hithelton" }
Returns: {0 }
{"a" }
{"the" }
Returns: { }