Full Chapter Daily Coding Problem Get Exceptionally Good at Coding Interviews by Solving One Problem Every Day Second Edition Lawrence Wu PDF
Full Chapter Daily Coding Problem Get Exceptionally Good at Coding Interviews by Solving One Problem Every Day Second Edition Lawrence Wu PDF
https://textbookfull.com/product/creative-thinking-and-problem-
solving-fabian/
https://textbookfull.com/product/problem-solving-with-c-walter-j-
savitch/
https://textbookfull.com/product/introduction-to-polymer-science-
and-chemistry-a-problem-solving-approach-second-edition-chanda/
https://textbookfull.com/product/problem-solving-for-new-
engineers-what-every-engineering-manager-wants-you-to-know-1st-
edition-melisa-buie/
Python Programming Using Problem Solving Approach
Thareja Reema
https://textbookfull.com/product/python-programming-using-
problem-solving-approach-thareja-reema/
https://textbookfull.com/product/problem-solving-in-mathematics-
education-1st-edition-peter-liljedahl/
https://textbookfull.com/product/introduction-to-cryptography-
with-coding-theory-3rd-edition-lawrence-c-washington-wade-trappe/
https://textbookfull.com/product/strategic-thinking-in-complex-
problem-solving-1st-edition-arnaud-chevallier/
https://textbookfull.com/product/engineering-problem-solving-
with-c-fourth-edition-delores-maria-etter/
Daily Coding Problem
Alex Miller and Lawrence Wu
1
2
All rights reserved. No part of this book may be reproduced in any form or by any
electronic or mechanical means, including information storage and retrieval systems,
without permission in writing from the publisher, except in the case of brief quota-
tions embodied in critical reviews and certain other noncommercial uses permitted
by copyright law. For more information, email the authors at founders@dailycoding-
problem.com.
SECOND EDITION
ISBN 978-1-7932966-3-4
( '
10987654321
Alex: For Mom, Dad,Jordan, Hannah, and Zaddy
3
Contents
Contents 5
I Data Structures 17
1 Arrays 19
1.1 Get product of all other elements . 20
1.2 Locate smallest window to be sorted 22
1.3 Calculate maximum subarray sum . 24
1.4 Find number of smaller elements to the right . 26
2 Strings 29
2.1 Find anagram indices 29
2.2 Generate palindrome pairs 32
2.3 Print zigzag form . . . . . 34
2.4 Determine smallest rotated string . 36
3 Linked Lists 41
3.1 Reverse linked list . . . . . . . . . . . . . . 42
3.2 Add two linked lists that represent numbers 44
3.3 Rearrange a linked list to alternate high-low 46
3.4 Find intersecting nodes of linked lists . 48
5
CONTENTS 6
6 Trees 73
6.1 Count unival trees . 75
6.2 Reconstruct tree from pre-order and in-order traversals 79
6.3 Evaluate arithmetic tree . . . . . . 81
6.4 Get tree level with minimum sum 83
8 Tries 93
8.1 Implement autocomplete system 95
8.2 Create PrefixMapSum class . . . 98
8.3 Find Maximum XOR of element pairs 102
9 Heaps 105
9 .1 Compute the running median 107
9 .2 Find most similar websites 109
9 .3 Generate regular numbers . 111
9.4 Build a Huffman tree 113
10 Graphs 119
10.1 Determine if a cycle exists . 122
10.2 Remove edges to create even trees 124
10.3 Create stepword chain .. 126
10.4 Beat Snakes and Ladders 128
10.5 Topological sort . . . 130
II Algorithms 143
12 Recursion 145
12.1 Tower of Hanoi . . . . . . . . 146
12.2 Implement regular expressions 149
12.3 Find array extremes efficiently 151
12.4 Play Nim . . . . . . . . . . . 154
CONTENTS 7
14 Backtracking 167
14.1 Compute flight itinerary 169
14.2 Solve Sudoku . . . . . . 171
14.3 Count Android unlock combinations . 174
16 Pathfinding 189
16.1 Dijkstra's algorithm 190
16.2 Bellman-Ford . 193
16.3 Floyd-Warshall 195
20 Applications 237
20.1 Ghost . . . . . . 238
20.2 Connect 4 . . . . 241
20.3 Cryptarithmetic . 247
CONTENTS 8
IV Design 271
Glossary 299
About the authors
Lawrence Wu is a software engineer who has worked at Google, Twitter, and Yelp
and has gained deep insight into each company's hiring practices. Most recently,
he has worked at Lyft on their self-driving division. Lawrence holds a degree in
computer science from the University ofToronto.
11
About this book
You may have bought this book because you are studying for an upcoming interview.
Or possibly you anticipate having a coding interview in the future. Or perhaps you
are simply interested in improving your knowledge of algorithms and data structures
by working through a set of problems! Whatever your use case, we hope you enjoy it.
The questions in this book have been chosen with practicality, clarity, and self-
improvement in mind. Each one is based on a real question that was asked recently
by top tech companies. The problems and explanations were then carefully edited so
that each one communicates a key idea that you can apply more generally. Finally,
we have organized these problems into chapters by topic, to ensure that you can
methodically build up your skills in specific areas.
At the beginning of each chapter we provide a crash course on the topic that follows,
but this book is no substitute for years of coding experience or a course in computer
science. As such, we assume that readers have experience with at least one program-
ming language, and have a basic familiarity with concepts such as graphs, recursion,
and hash tables.
The structure of this book is as follows. First, we introduce you to the most essential
data structures that pop up in coding interviews, such as linked lists, arrays, strings,
and hash tables. For each data structure, we offer a refresher on its advantages and
disadvantages, the time and space complexities of its operations, its implementation,
and what themes and key words to look for in order to recognize it.
13
CONTENTS 14
Third, we present a set of more advanced problems that require you to use the pre-
ceding data structures and algorithms in novel ways in order to solve real-world
applications. From deriving a perfect blackjack strategy to deciphering an alien dic-
tionary, these questions are designed to challenge you and widen your understanding
of what can be achieved with the right concepts and implementation.
Lastly, we address the topic of design. Interviewers like to gauge the ability of
candidates to understand tradeoffs between different approaches. As a result, it is not
uncommon to see problems with time and space constraints that require formulating
novel data structures. It has also become increasingly frequent for candidates to be
asked to design a high-level system that meets a particular need. Our :final chapters
on data structure and system design walk through each of these question types,
respectively, and provide a general strategy for approaching similar problems in the
future.
Before you jump in, we offer some general advice for working through the problems.
1. First, really try to solve each problem, even if it seems challenging, and even
if you aren't sure where to begin! Look for key words in the question, and
write out some pseudocode to get things started. Use the topic groupings to
your advantage: review the chapter introduction to see how a particular data
structure or algorithm may be relevant. This process of brainstorming and
engaging with the question will help to build your problem solving muscle
memory.
2. After giving the problem your best shot, read through the solution, looking
for not just how the algorithm works but why. What are the core concepts,
and to what other problems might they apply? About an hour later, and then
a week after, try to implement it again, this time without the solution.
3. Finally, stay positive! Many of these concepts are challenging, and without
CONTENTS 15
practice these data structures and algorithms may not seem intuitive. For ex-
ample, dynamic programming, a now-common technique, was first developed
by top mathematicians during the Cold War to optimize military operations!
Rather than trying to understand it all at once, put aside some time each day
to work through one or two problems, and let the material sink in gradually.
Good luck!
Part I
Data Structures
17
Arrays
Arrays are without a doubt the most fundamental data structure in computer science.
Under the hood, an array is represented as a fixed-size, contiguous block of memory
with 0(1) time to store and access an element. Because of this efficiency, many other
data structures frequently use arrays for their implementation, such as strings, stacks,
queues, and hash tables.
You can picture an array as a bounded row of labeled containers, starting at 0, where
you can quickly put items in, take them out, or look up a value from an index (or
label).
0 1 2 3 4 5 6 7
For example, in the diagram above, we have an array of length 8. We can set and
get the value associated with the third index in constant time using the following
operations:
array[2] = 'foo'
x = array[2] # 'foo'
19
. CHAPTER 1. ARRAYS 20
Finally, arrays have a fixed bound, which means they may not be suitable for applica-
tions where the size of the collection of elements is not known ahead of time. In an
interview setting, you should be careful of off-by-one errors that lead to trying to
access an element outside the range of the array.
Python does not have native support for arrays; typically, you'll use the list data
structure, which dynamically resizes under the hood. What this means is that to you,
the developer, it seems like the list is unbounded. In reality, as the list grows, the
data structure may allocate a larger (typically twice the current size) array, copy all
its elements to the larger one, and then use that as the underlying array.
In this chapter, we'll look at some common interview questions involving arrays and
strategies for solving them. Let's get started!
Given an array of integers, return a new array such that each element at index i of
the new array is the product of all the numbers in the original array except the one
at i.
For example, if our input was [ 1, 2, 3, 4, 5], the expected output would be [ 120,
60, 40, 30, 24]. Ifourinputwas [3, 2, 1],theexpectedoutputwouldbe [2,
3, 6].
Solution
This problem would be easy with division: an optimal solution could just find the
product of all numbers in the array and then divide by each of the numbers. To
solve this without division, we will rely on a common technique in array problems:
precomputing results from subarrays, and building up a solution from these results.
First note that to find the value associated with the i th element, we must compute
the product of all numbers before i and the product of all numbers after i. If we
could efficiently calculate these two, we could then simply multiply them to get our
desired product.
In order to find the product of numbers before i, we can generate a list of prefix
products. Specifically, the i th element in the list will be a product of all numbers
including i. Similarly, we can generate a list of suffix products. Finally, for each index
we can multiply the appropriate prefix and suffix values to obtain our solution.
def products(nums):
# Generate prefix products.
prefix_products = []
for num in nums:
if prefix_products:
prefix_products.append(prefix_products[-1] * num)
else:
prefix_products.append(num)
result.append(suffix_products[i + 1])
etif i == len(nums) - 1:
result.append(prefix_products[i - 1])
else:
result.append(
prefix_products[i - 1] * suffix_products[i + 1]
return result
This runs in O(n) time and space, since iterating over the input array takes O(n)
time and the prefix and suffix arrays take up 0( n) space.
Given an array of integers that are out of order, determine the bounds of the smallest
window that must be sorted in order for the entire array to be sorted. For example,
given [ 3 , 7 , 5 , 6 , 9] , you should return ( 1 , 3 ) .
Solution
One method we can try is to first find out what the array elements would look like
when sorted. For example, [ 3, 7, 5, 6, 9], after sorting, becomes [ 3, 5, 6, 7,
9]. We can see that the first and last elements remain unchanged, whereas the middle
elements are altered. Therefore, it suffices to take the first and last altered elements
as our window.
def window(array):
left, right= None, None
s = sorted(array)
for i in range(len(array)):
if array[i] != s[i] and left is None:
left= i
etif array[i] != s[i]:
right= i
CHAPTER 1. ARRAYS 23
This solution takes 0( n log n) time and space, since we create a sorted copy of the
original array.
Often when dealing with arrays, a more efficient algorithm can be found by looping
through the elements and computing a running minimum, maximum, or count. Let's
see how we can apply this here.
Suppose instead that we traversed the array, from left to right, and took note of
whether each element was less than the maximum seen up to that point. This
element would have to be part of the sorting window, since we would have to move
the maximum element past it.
As a result, we can take the last element that is less than the running maximum, and
use it as our right bound. Similarly, for our left bound, we can traverse the array from
right to left, and find the last element that exceeds the running minimum.
This will take two passes over the array, operating in O(n) time and 0(1) space.
def window(array):
left, right= None, None
n = len(array)
max_seen, min_seen = -float("inf"), float("inf")
for i in range(n):
max_seen = max(max_seen, array[i])
if array[i] < max_seen:
right= i
Given an array of numbers, :find the maximum sum of any contiguous subarray of
the array. For example, given the array [34, -50, 42, 14, -5, 86], the maximum
sum would be 137, since we would take elements 42, 14, -5, and 86. Given the array
[ -5, -1, -8, -9], the maximum sum would be 0, since we would choose not to
take any elements.
Follow-up: What if the elements can wrap around? For example, given [ 8, -1, 3,
4], return 15, as we choose the numbers 3, 4, and 8 where the 8 is obtained from
wrapping around.
Solution
The brute force approach here would be to iterate over every contiguous subarray
and calculate its sum, keeping track of the largest one seen.
def max_subarray_sum(arr):
current_max = 0
for i in range(len(arr) - 1):
for j in range(i, len(arr)):
current_max = max(current_max, sum(arr[i:j]))
return current_max
This would run in O(n 3 ) time. How can we make this faster?
We can work backwards from our desired solution by iterating over the array and
looking at the maximum possible subarray that can be made ending at each index.
For each index, we can either include the corresponding element in our sum or
exclude it.
As we iterate over our array, we can keep track of the maximum subarray we've seen
so far in a variable called max_so_ far. Whenever we find a larger subarray ending at
CHAPTER 1. ARRAYS 25
def max_subarray_sum(arr):
max_ending_here = max_so_far = 0
for x in arr:
max_ending_here = max(x, max_ending_here + x)
max_so_far = max(max_so_far, max_ending_here)
return max so far
Th.is algorithm is known as Kadane's algorithm, and it runs in O(n) time and 0(1)
space.
We split the follow-up problem into two parts. The :first part is the same as before:
finding the maximum subarray sum that doesn't wrap around. Next, we compute the
maximum subarray sum that does wrap around, and take the maximum of the two.
To get the largest wrap-around sum, we can use a little trick. For any subarray that
wraps around, there must be some contiguous elements that are excluded, and these
elements actually form the minimum possible subarray! Therefore, we can :first :find
the minimum subarray sum using exactly the method above, and subtract this from
the array's total.
For example, in the example above, the minimum subarray is [ -1], with a total of
-1. We then subtract this from the array total, 14, to get 15.
def maximum_circular_subarray(arr):
max_subarray_sum_wraparound = sum(arr) - min_subarray_sum(arr)
def max_subarray_sum(arr):
max_ending_here max_so_far 0
for x in arr:
max_ending_here = max(x, max_ending_here + x)
max_so_far = max(max_so_far, max_ending_here)
def min_subarray_sum(arr):
min_ending_here = min_so_far = 0
for x in arr:
min_ending_here = min(x, min_ending_here + x)
min_so_far = min(min_so_far, min_ending_here)
Given an array of integers, return a new array where each element in the new array
is the number of smaller elements to the right of that element in the original input
array.
Solution
A naive solution for this problem would simply be to create a new array, and for each
element count all the smaller elements to the right of it.
CHAPTER 1. ARRAYS 27
def smaller_counts_naive(lst):
result= []
for i, num in enumerate(lst):
count= sum(val < num for val in lst[i + 1:])
result.append(count)
return result
The index will be how many elements on the right are smaller.
import bisect
def smaller_counts(lst):
result = []
seen=[]
return list(reversed(result))
Strings are an unavoidable part of programming. Every word in this sentence, and
this whole book itself, can be considered a string! As a result there's a good chance
you'll be asked a question involving strings in an interview question.
Behind the scenes, the contents of a string are typically stored in a read-only sequential
array in memory, meaning that strings are immutable. In other words, you can reassign
a string variable to a new value, but you cannot change a particular character in the
underlying array.
The most common operations performed on strings are indexing to get a particular
character or substring, joining two strings together by concatenation, ai;id splitting
by a delimiter.
Expect to be asked about string rotations, reversals, prefixes and suffixes, and sorting.
We'll explore these topics in the following questions.
Given a word wand a strings, find all indices ins which are the starting locations
of anagrams of w. For example, given w is ab ands is abxaba, return [ 0, 3, 4].
29
Another random document with
no related content on Scribd:
"His past!" I said. "What about that?"
"I mean to marry him, whatever mother may say," Agneta said
presently. "I shall soon be of age, and then I will do as I like. She
shall not spoil my life."
"Oh, Agneta, don't talk like that! It frightens me," I said. "You might
spoil your life just by taking your own way."
"Only that we are so blind and ignorant that we cannot know what is
good for us unless we are sure that God is guiding our steps," I said
timidly. "I did not at all like having to give up my studies and come
down here; but it was God's will for me, and I know now that it is for
my good. If only you would be patient, Agneta, and leave your life in
God's hands, He would bring it about in His own good time if—"
"Oh, don't preach to me, Nan, if you please. I cannot stand that. I
see I have shocked you, but I cannot help it. You won't say anything
to your aunt, will you?"
"Of course I shall not repeat what you have told me in confidence,"
was my hasty reply.
CHAPTER XI
THE UNFORESEEN BEFALLS
IN spite of the fears she had exhibited on her arrival, Paulina Dicks
was apparently content with her life at "Gay Bowers." As she
appeared cheerful, and was never one to disguise her feelings, we
could safely conclude that she was not dull. Of a highly nervous,
energetic temperament, she was for ever planning new enterprises,
and whatever she took in hand she accomplished most thoroughly.
When she wearied of cycling, she took to driving about the country
roads in Aunt Patty's little old-fashioned chaise. Sometimes her
father and sometimes Miss Cottrell accompanied her. Aunt was
much afraid that she overdrove the fat little pony, that had grown
accustomed to an easy life; but Paulina declared that he was far too
fat, and she was doing him good by rousing him from the silly jog-trot
which was the pace he preferred.
"What Pollie Dicks wants, she'll have," said her father admiringly,
and he showed himself willing to meet all the expense which her
scheme involved.
But his words did not prove true in this instance, for Paulina had to
put up with something she did not at all desire and was far from
foreseeing as she made her plans, and with a business-like air wrote
a list of the things she would order when next she went to London.
Not a week passed without her going to town, and sometimes she
would go two or three times in the week. Her father seldom
accompanied her. He found the Chelmsford shops good enough for
him, and if he wanted anything special his daughter could get it. The
bustle and stir of London, so dear to Paulina, no longer attracted
him. He was taking kindly to a country life, and found himself the
better for it.
One morning when Paulina came down prepared to start for London,
as she had informed us on the previous evening was her intention, I
noticed that she was pale and heavy-eyed and took little breakfast.
She nodded.
"Oh, it is nothing; I must go," she said impatiently. "I hate putting
things off. I want to start the golf while this fine weather lasts."
It was a lovely June morning. When I had seen Paulina off, I went
round the garden with basket and scissors, gathering fresh flowers
for the vases. I came to the corner where was Miss Cottrell's tiny
domain, and found her exhibiting its beauties to Alan Faulkner. She
had certainly done wonders in the short time she had had it in her
care. The little parterre was gay with flowers. She was especially
proud of a cluster of fine carnations of the striped variety which I
believe is commonly known as "strawberries and cream."
"I will give you a buttonhole," said Miss Cottrell eagerly. "Your
scissors, please, Miss Darracott."
"They are both fine," said Miss Cottrell. "What does it matter?"
But I had already discovered that in spite of his quiet manner Alan
Faulkner had a very strong will. Even in trifles I generally found
myself gently constrained to yield to him. So the flowers were
exchanged, and, to make sure that he would not give it away, Miss
Cottrell herself secured the Professor's at his buttonhole. Then he
and I took a stroll round the garden. I asked him about an article
which had recently appeared in one of the reviews. He said he had
the review in question, and would lend it to me if I cared to see it. He
went into the house to fetch the periodical, and while I sauntered
near the door, Miss Cottrell came up.
"I am glad he gave you that carnation," she said, looking fondly at it,
"but I am afraid Miss Pollie will get the other. She made him give her
the rose he was wearing last night."
"I am awfully amused at all I see," she went on. "Professor Faulkner
is pretty deep. What a smart dodge it is his teaching her to play golf!"
"Don't you?" she returned with a laugh. "Well, I must say, Miss
Darracott, although you can talk so cleverly, you are stupid over
some things. It is plain enough to me that the Professor means to
win the millionaire's daughter."
I cannot describe the aversion I felt towards Miss Cottrell when she
said that. Before she could add another word Mr. Faulkner appeared
with the review. When I came to look into it, I found that it contained
an article from his pen. I read this first, for it interested me far more
than the one of which I had spoken to him. It was the first thing of his
which I had read, and it struck me as very clever.
"Well, Pollie Dicks, you look as if going to town agreed with you!"
I tried to persuade her to lie down, but she insisted on preparing for
dinner as usual. But, though she sat down with the rest, she could
eat nothing, and was soon obliged to leave the table.
Aunt Patty went to her a little later, saw her to bed, and did what she
could for her. Mr. Dicks was sorely perturbed by the indisposition of
his darling. He hung over her, suggesting all kinds of possible and
impossible remedies, till Paulina peremptorily ordered him to go
away, and leave her in peace, whereupon he retired and despatched
a note to the doctor, who had attended him when he was ill begging
him to come to "Gay Bowers" as soon as possible on the following
day. After a while Paulina seemed inclined to sleep, and aunt and I
went to bed, hoping that her ailment would prove only temporary.
Her father wished that some one should sit up with her, but she
would not hear of it, and, as usual, obtained her own way.
I don't know what it was that made me awake about two hours later,
but in the stillness of the night I was aware of movements in the
adjoining room. Fearing that Paulina was worse, I rose, slipped on
my dressing gown, and went into the next room. A night-light was
burning there, and by its dim rays I saw Paulina standing by the
washstand, bathing her head with cold water. She said the pain she
had in it was terrible. I touched her forehead; it was burning hot, and
so were her hands, yet every now and then she shivered. I knew
enough of illness to be sure that this meant fever of some kind or
other.
With some difficulty I persuaded her to lie down again. I placed wet
bandages on her forehead, and kept changing them as they grew
warm.
"Oh, Nan, I feel so ill—don't leave me!" she said more than once,
and I promised that I would stay with her. When, after a while, she
grew drowsy, I stole into my room and brought away my blankets, in
which I rolled myself up on Paulina's sofa, for the night was growing
chill, as it generally does towards dawn. But I did not lie there long,
for Paulina was soon tossing to and fro and moaning again.
As the grey light of early morning was creeping into the room she
suddenly sat up in bed, her fevered face looking haggard and
distraught, and exclaimed in a tone of desperate conviction:
"Oh, Nan, I know what this means. I guess I've got smallpox."
"I guess I'm right," she said gloomily. "You know how bad it has been
in London."
"Yes; but it is better now," I said. "The epidemic is over. There were
only ten cases last week."
"I don't care," she persisted. "I guess I'm one of the next ten. You
know it was very bad when first we came to London and father
wanted me to be vaccinated, and I would not. I thought I would trust
to my luck."
"I feel perfectly sure that you are mistaken," I said, "so pray dismiss
that idea from your mind."
"I can't," she said. "It is such a horrible disease to have, and spoils
one's appearance so. I don't know what Charlie would do."
"Charlie?" I repeated.
How long it seemed ere there was any sound of movement in the
household! When at last I heard a step on the stairs I opened the
door and looked out. Miss Cottrell was descending, clad in the short
rough skirt and jersey which she donned for hard work in the garden.
She loved to toil there for an hour before any one else was astir. She
saw me and turned back to ask how Paulina was. She came into the
room, looked critically at the sick girl and drew my attention to a rash
which was beginning to appear on her face and neck. When she had
shaken up the pillows and made the bed more comfortable, which
she did in the deft manner of one accustomed to such a task,
speaking cheerily to Paulina the while, Miss Cottrell beckoned to me
to follow her from the room.
"This is scarlet fever," she said, before she had properly closed the
door.
"I don't think I am mistaken," said Miss Cottrell. "I have seen it
before, indeed, I've had it myself. I need not tell you to be brave,
Miss Darracott. We must keep our heads in this emergency or there
will be a panic in the household."
"Yes, yes," I said. "Mr. Dicks has written to ask Dr. Poole to call, but
something might be done to hasten his arrival."
"Certainly; a messenger must be sent for him," said Miss Cottrell. "I'll
go and break the news to Mrs. Lucas. You had better go back into
the room for the present, for you must not go near your cousin. Have
you ever had scarlet fever, by the by?"
"Then I will soon come and relieve you," she said. "There is not great
danger of infection yet, but we must take every precaution."
When I re-entered the room I found Paulina in tears and knew that
she must have overheard Miss Cottrell's diagnosis.
"Oh, come, you must not meet trouble half-way," I said. "I am not yet
absolutely sure that it is scarlet fever; but if Miss Cottrell is right, you
know that numbers of people have that fever who do not die of it."
Never shall I forget the look on her face, nor the sound of her voice
as she said these words. Face to face with the "shadow feared of
man", she felt herself utterly helpless. But a Helper there was. I knew
the strength of my own faith as I saw her need. I had to speak,
though the words were weak and poor in which I tried to give her
comfort.
"Do not be afraid, Paulina; you will not be alone. You know the Bible
says that neither life nor death can separate us from the love of
Christ. Your life is in His hands, the hands that for your sake were
nailed to the cross. Is it not a comfort to remember that?"
"It means nothing to me," she said drearily. "You know that I have
never been particularly religious. I cannot grasp what you say."
"That does not matter, dear, if only you will give yourself into the
keeping of the Lord Jesus," I said. "Our safety consists not in our
taking hold of Christ, but in His taking hold of us. The grasp of our
faith is too often weak and wavering, but neither life nor death can
draw us from the embrace of His love. Ask Him to take you into His
tender keeping, and bring you safely through all trouble."
"I cannot—I don't know how!" she whispered. "You ask Him, Nan."
I don't know how I did it—I had never prayed audibly in any one's
presence—but I knelt beside Paulina then, and asked the Lord to
hold her ever in His loving care, and to bring her safely through this
illness.
I had not long risen from my knees when Miss Cottrell entered the
room. She brought a cup of tea for Paulina, and she said brightly as
she set down the tray:
"There's one for you in my room, Miss Darracott. You will also find a
bath prepared for you, and clothes for you to put on. Your aunt gave
them to me, since you cannot go to your own room at present."
"That means that you are in quarantine, Nan," said Paulina. "You
seem pretty certain about the matter," she added, turning to Miss
Cottrell.
"I know a few things," said that spinster with a smile, "but we shall
soon know whether I am right, for Mr. Jack Upsher has ridden into
Chelmsford to fetch the doctor. Now say 'Good-bye' to Miss
Darracott, for I have constituted myself your nurse for the present."
Tears sprang anew to Paulina's eyes. She stretched out her arms
appealingly to me, but Miss Cottrell interposed her person, and
gently pushed me towards the door.
"Stay in my room till I come to you," was Miss Cottrell's last mandate.
Thus strangely did the new day begin. How little we know what is
before us!
CHAPTER XII
AT HOBBES'S COTTAGE
Aunt Patty and I have often said since that we do not know what we
should have done without Miss Cottrell at this juncture. She rose to
the occasion in the most wonderful way, and showed herself so
thoughtful and expeditious that we could quite understand how the
Lady Mowbray, of whom we had heard so much, had found her
invaluable. She it was who suggested the house to which Paulina
was conveyed, a modern "villa" belonging to a widow who was glad
to let her best apartments, and was willing to receive an infectious
case on the handsome terms offered by Mr. Dicks.
"Well, Nan," she said with a smile as she opened the door, "is your
patience pretty well exhausted?"
"Poor child! It is no wonder," she said. "Now come into the garden
with me. We will talk in the fresh air."
"You must not let it frighten you," Aunt Patty said. "The doctor quite
hopes that you have escaped infection, but for the sake of my guests
it is right to guard against the possibility of a second case in the
house. I cannot bear to send you away, but Mrs. Hobbes has a nice
little room which she lets sometimes, and if you would not mind
sleeping there just for a week till we see how things turn out."
"Of course we can come to see you," said my aunt, "and you need
not avoid us as long as you keep well. It is chiefly for Agneta's sake
that I take this precaution. I do not think the gentlemen are in any
danger, but I want to assure Mrs. Redmayne that I am taking all
possible care of her child."
"Oh, there is little fear of that," said my aunt hastily. "I am glad that
Paulina likes Miss Cottrell better than you do."
"Ah, but she has gone up immensely in my estimation during the last
few hours!" was my reply.
That was surely the longest day I had ever known in my life. I was
not more than half-a-mile from "Gay Bowers," yet I seemed quite cut
off from all the pleasant life there. No one came to see how I was
settling in. Aunt Patty, I knew, had far too much depending on her.
Mr. Faulkner had gone up to town in the morning, and I could not be
sure that he had heard of the calamity which had befallen us.
Colonel Hyde was doubtless still entertaining Agneta. Jack, whose
examination was now close at hand, was working with desperate
energy. I had no right to feel myself neglected, yet a sore, forlorn
sense of being forsaken crept over me.
"Afraid!" he repeated. "Of what should I be afraid? But I hope you will
not stay here long. We missed you so much last evening. It seemed
so strange to see nothing of you all day."
"I had a pleasant proof that I was not forgotten," I said. "Thank you
so much for bringing me those papers. I will get them for you."
"Pray do not trouble unless you wish to be rid of them," he said. "I do
not want them, and you can hardly have read them all yet."
"Indeed, I read very little last night; I felt too tired and unsettled," I
said. "But I liked having them."
His steady eyes met mine with that look which seemed to read my
very soul. I had a strange feeling that he knew all the nervous,
foolish ideas that had passed through my mind.
"Do you know how Paulina is this morning?" I asked hurriedly. "Has
aunt heard?"
"Yes, Mr. Dicks went down to 'Ivy House' at a very early hour and
brought back word that his daughter had passed a restless night," he
replied. "Still, I do not think there is any cause for anxiety; the fever
must take its course."
"Poor Paulina!" I said. "It is hard to imagine her anything but restless
under the circumstances."
"No, I believe he does not even enter the house. Miss Cottrell gives
her report from a window. This is her opportunity."
I could not help laughing, though I felt it was mean when the spinster
was acting so bravely.
"Well, you know, he has not always had a great deal of her
company," Mr. Faulkner replied; "but Mrs. Lucas is puzzled to think
how she can best divert his thoughts. By the by, I was to say that he
is coming to take you for a drive presently. He has forestalled me, for
I was going to ask you to cycle with me this afternoon."
"How could she?" he asked with a smile. "Miss Cottrell is not at 'Gay
Bowers.' This is the one you gave me."
"Did you not?" he asked. "At least you gave me back one after you
had worn it a few seconds, thus giving it a new and rare value."
Who would have thought that a learned man like Professor Faulkner
could have said a thing like that? It was the sort of compliment Jack
Upsher might have paid me, and I should have thought it silly from
his lips; but somehow I was not impressed with its silliness at this
moment. I should have been annoyed with Jack for saying it, but I
was not annoyed with Alan Faulkner. I recalled the words many
times in the course of that day and ever with a joyous thrill of the
heart. What little things make up the sum of life! To this day I can
never see what is called a "strawberry and cream" carnation without
recalling that hour and the sweetness of the strange new hope that
then awoke to life.
Ere Alan Faulkner could make any rejoinder, there was the sound of
another bicycle rushing down the lane and Jack Upsher came in
sight. He had turned aside on his way to Chelmsford in order to
assure himself that I had not yet developed scarlet fever.
CHAPTER XIII
OLIVE'S HAPPINESS
JACK seemed rather annoyed to find that I was not alone, though Alan
Faulkner immediately decided that it was time he went to his morning's work
and rode off. Jack wanted me to ride with him later in the day, and was vexed
when he learned that Mr. Dicks was going to take me for a drive. His ill-
humour increased when I told him that I had promised to ride with Mr.
Faulkner on the following day.
"It is too bad!" he said morosely. "You might have kept the last day for me!"
I had forgotten that the day was so near. I felt almost frightened as I realised
it.
"Oh, Jack, I do hope you will do well!" I said. "Do you feel fairly ready?"
"I don't feel in the least fit," he said. "I believe I shall make a horrid mess of it
again, and then you will have nothing more to say to me, I suppose. In that
case I shall just enlist as a Tommy."
"Don't talk nonsense!" I said severely. "You will not fail this time; you cannot,
and must not. You really have worked, you know."
"Thanks for giving me so much credit," he said, "but that has really little to do
with it. I am unlucky at these things. The old fogeys who prepare the papers
are sure to hit upon questions that will bowl me out."
"Rubbish!" I said. "Make up your mind to succeed, and you will come out all
right."
"You might have let me have a last ride with you," he said reproachfully.
"It won't be the last, I hope, but there is nothing to hinder you from joining us
to-morrow," I said, feeling, however, rather blank as I made the suggestion.
"Thank you very much," he said sarcastically; "but I have not the least desire
to make an unwelcome third."
"Make a welcome fourth, then," I said. "I dare say Agneta will be pleased to
come too."
But this did not do either. He was in a very perverse mood that morning. It was
a relief to me when he had departed, having lingered till it was necessary for
him to ride at break-neck speed into Chelmsford if he would arrive punctually
at his tutor's. I felt very anxious that he should do well in his examination, and
gave him every wise admonition that my own experience could suggest. For
his own sake, and for his father's, it would be a thousand pities if he failed
again. Foolish boy as Jack often showed himself to be, I knew that he was
brave and manly, and I believed, with my father, that he would make a fine
soldier.
"I am looking for Poole," he said. "He ought to be here by now. If he sees the
least cause for fear, I shall telegraph at once for one of the first physicians
from London."
When we reached the gate of "Ivy House," he pointed out to me the windows
of the room in which Paulina lay. Just then Miss Cottrell's head appeared
above one of the muslin blinds. She smiled and nodded briskly as she saw us.
"She looks cheerful," I remarked. "I don't think she can be very uneasy about
her patient."