Skip to content

Commit 3af1589

Browse files
author
liwentian
committed
fd
1 parent 3b47d8e commit 3af1589

File tree

7 files changed

+113
-14
lines changed

7 files changed

+113
-14
lines changed

ebook/Backtracking.aux

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
\@writefile{toc}{\contentsline {section}{\numberline {1.2}Wildcard Matching}{2}{section.1.2}}
1212
\@writefile{toc}{\contentsline {subsubsection}{Description}{2}{section*.3}}
1313
\@writefile{toc}{\contentsline {subsubsection}{Solution}{2}{section*.4}}
14+
\@writefile{toc}{\contentsline {section}{\numberline {1.3}Letter Combinations of a Phone Number}{3}{section.1.3}}
15+
\@writefile{toc}{\contentsline {subsubsection}{Description}{3}{section*.5}}
16+
\@writefile{lof}{\contentsline {figure}{\numberline {图\nobreakspace 1-1}{ \ignorespaces Phone Keyboard}}{3}{section*.5}}
17+
\newlabel{fig:phone-keyboard}{{1-1}{3}{Description}{section*.5}{}}
18+
\@writefile{toc}{\contentsline {subsubsection}{Solution}{3}{section*.6}}
1419
\FN@pp@footnotehinttrue
1520
\@setckpt{Backtracking}{
16-
\setcounter{page}{3}
21+
\setcounter{page}{5}
1722
\setcounter{equation}{0}
1823
\setcounter{enumi}{0}
1924
\setcounter{enumii}{0}
@@ -23,20 +28,20 @@
2328
\setcounter{mpfootnote}{0}
2429
\setcounter{part}{0}
2530
\setcounter{chapter}{1}
26-
\setcounter{section}{2}
31+
\setcounter{section}{3}
2732
\setcounter{subsection}{0}
2833
\setcounter{subsubsection}{0}
2934
\setcounter{paragraph}{0}
3035
\setcounter{subparagraph}{0}
31-
\setcounter{figure}{0}
36+
\setcounter{figure}{1}
3237
\setcounter{table}{0}
33-
\setcounter{FancyVerbLine}{22}
38+
\setcounter{FancyVerbLine}{46}
3439
\setcounter{pp@next@reset}{1}
3540
\setcounter{@fnserial}{0}
3641
\setcounter{Item}{0}
3742
\setcounter{Hfootnote}{0}
3843
\setcounter{Hy@AnnotLevel}{0}
39-
\setcounter{bookmark@seq@number}{3}
44+
\setcounter{bookmark@seq@number}{4}
4045
\setcounter{parentequation}{0}
4146
\setcounter{section@level}{3}
4247
}

ebook/Backtracking.tex

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,71 @@ \subsubsection{Solution}
9292
}
9393
\end{Code}
9494

95+
\newpage
96+
97+
\section{Letter Combinations of a Phone Number}
98+
99+
\subsubsection{Description}
100+
Given a digit string, return all possible letter combinations that the number could represent.
101+
102+
A mapping of digit to letters (just like on the telephone buttons) is given below.
103+
104+
\begin{center}
105+
\includegraphics[width=150pt]{phone.png}\\
106+
\figcaption{Phone Keyboard}\label{fig:phone-keyboard}
107+
\end{center}
108+
109+
\textbf{Input:} Digit string \code{"23"}
110+
111+
\textbf{Output:} \code{["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]}.
112+
113+
\subsubsection{Solution}
114+
115+
\begin{Code}
116+
private final String[] ARR = {
117+
"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"
118+
};
119+
120+
public List<String> letterCombinations(String digits) {
121+
List<String> list = new LinkedList<>();
122+
if (!digits.isEmpty()) {
123+
helper(digits, 0, list, "");
124+
}
125+
return list;
126+
}
127+
128+
private void helper(String digits, int start, List<String> list, String s) {
129+
if (start >= digits.length()) {
130+
list.add(s);
131+
return;
132+
}
133+
int n = digits.charAt(start) - '0';
134+
for (char c : ARR[n].toCharArray()) {
135+
helper(digits, start + 1, list, s + c);
136+
}
137+
}
138+
139+
public List<String> letterCombinations2(String digits) {
140+
LinkedList<String> queue = new LinkedList<String>();
141+
if (digits.length() == 0) {
142+
return queue;
143+
}
144+
145+
Queue<String> next = new LinkedList<>();
146+
queue.add("");
147+
148+
for (int i = 0; i < digits.length() && !queue.isEmpty(); ) {
149+
String s = queue.poll();
150+
int n = digits.charAt(i) - '0';
151+
for (char c : ARR[n].toCharArray()) {
152+
next.add(s + c);
153+
}
154+
if (queue.isEmpty()) {
155+
queue.addAll(next);
156+
next.clear();
157+
i++;
158+
}
159+
}
160+
return queue;
161+
}
162+
\end{Code}

ebook/images/phone.png

92 KB
Loading

ebook/leetcode.log

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex 2017.9.4) 5 SEP 2017 10:52
1+
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex 2017.9.4) 5 SEP 2017 11:06
22
entering extended mode
33
restricted \write18 enabled.
44
%&-line parsing enabled.
@@ -1881,7 +1881,32 @@ File: eu1lmtt.fd 2009/10/30 v1.6 Font defs for Latin Modern
18811881

18821882

18831883

1884-
]) [2]
1884+
] [2]
1885+
File: images/phone.png Graphic file (type QTm)
1886+
1887+
<use "images/phone.png" >
1888+
\g__fontspec_family_LatinModernMono_int=\count195
1889+
.................................................
1890+
. fontspec info: "no-font-shape"
1891+
.
1892+
. Could not resolve font Latin Modern Mono/B (it probably doesn't exist).
1893+
.................................................
1894+
.................................................
1895+
. fontspec info: "defining-font"
1896+
.
1897+
. Font family 'LatinModernMono(0)' created for font 'Latin Modern Mono' with
1898+
. options [].
1899+
.
1900+
. This font family consists of the following NFSS series/shapes:
1901+
. - 'normal' (m/n) with NFSS spec.: <->"Latin Modern
1902+
. Mono/OT:script=latn;language=DFLT;"
1903+
. - 'small caps' (m/sc) with NFSS spec.: - 'italic' (m/it) with NFSS spec.:
1904+
. <->"Latin Modern Mono/I/OT:script=latn;language=DFLT;"
1905+
. - 'italic small caps' (m/itsc) with NFSS spec.: - 'bold italic' (bx/it)
1906+
. with NFSS spec.: <->"Latin Modern Mono/BI/OT:script=latn;language=DFLT;"
1907+
. - 'bold italic small caps' (bx/itsc) with NFSS spec.:
1908+
.................................................
1909+
[3]) [4]
18851910
No file leetcode.ind.
18861911
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 42.
18871912
Package atveryend Info: Empty hook `AfterLastShipout' on input line 42.
@@ -1891,12 +1916,12 @@ Package atveryend Info: Empty hook `AtEndAfterFileList' on input line 42.
18911916
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 42.
18921917
)
18931918
Here is how much of TeX's memory you used:
1894-
29119 strings out of 493591
1895-
550521 string characters out of 6143547
1896-
566578 words of memory out of 5000000
1897-
32171 multiletter control sequences out of 15000+600000
1898-
5028 words of font info for 47 fonts, out of 8000000 for 9000
1919+
29160 strings out of 493591
1920+
551638 string characters out of 6143547
1921+
566615 words of memory out of 5000000
1922+
32193 multiletter control sequences out of 15000+600000
1923+
5076 words of font info for 53 fonts, out of 8000000 for 9000
18991924
1347 hyphenation exceptions out of 8191
1900-
65i,11n,77p,10414b,396s stack positions out of 5000i,500n,10000p,200000b,80000s
1925+
65i,11n,77p,10414b,588s stack positions out of 5000i,500n,10000p,200000b,80000s
19011926

1902-
Output written on leetcode.pdf (2 pages).
1927+
Output written on leetcode.pdf (4 pages).

ebook/leetcode.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
\BOOKMARK [0][-]{chapter.1}{\376\377\173\054\0001\172\340\000\040\000\040\000B\000a\000c\000k\000t\000r\000a\000c\000k\000i\000n\000g}{}% 1
22
\BOOKMARK [1][-]{section.1.1}{\376\377\0001\000.\0001\000\040\000R\000e\000g\000u\000l\000a\000r\000\040\000E\000x\000p\000r\000e\000s\000s\000i\000o\000n\000\040\000M\000a\000t\000c\000h\000i\000n\000g}{chapter.1}% 2
33
\BOOKMARK [1][-]{section.1.2}{\376\377\0001\000.\0002\000\040\000W\000i\000l\000d\000c\000a\000r\000d\000\040\000M\000a\000t\000c\000h\000i\000n\000g}{chapter.1}% 3
4+
\BOOKMARK [1][-]{section.1.3}{\376\377\0001\000.\0003\000\040\000L\000e\000t\000t\000e\000r\000\040\000C\000o\000m\000b\000i\000n\000a\000t\000i\000o\000n\000s\000\040\000o\000f\000\040\000a\000\040\000P\000h\000o\000n\000e\000\040\000N\000u\000m\000b\000e\000r}{chapter.1}% 4

ebook/leetcode.pdf

82.4 KB
Binary file not shown.

ebook/leetcode.synctex.gz

4.24 KB
Binary file not shown.

0 commit comments

Comments
 (0)