Small fixes
This commit is contained in:
parent
d4ea994907
commit
797035fd8a
13 changed files with 43 additions and 43 deletions
12
luku08.tex
12
luku08.tex
|
|
@ -245,13 +245,13 @@ Since both the left and right pointer
|
|||
move $O(n)$ steps during the algorithm,
|
||||
the time complexity is $O(n)$.
|
||||
|
||||
\subsubsection{2SUM-problem}
|
||||
\subsubsection{2SUM problem}
|
||||
|
||||
\index{2SUM-problem}
|
||||
\index{2SUM problem}
|
||||
|
||||
Another problem that can be solved using
|
||||
the two pointers method is the following problem,
|
||||
also known as the \key{2SUM-problem}:
|
||||
also known as the \key{2SUM problem}:
|
||||
We are given an array of $n$ numbers and
|
||||
a target sum $x$, and our task is to find two numbers
|
||||
in the array such that their sum is $x$,
|
||||
|
|
@ -414,13 +414,13 @@ number such that the sum is $x$.
|
|||
This can be done by performing $n$ binary searches,
|
||||
and each search takes $O(\log n)$ time.
|
||||
|
||||
\index{3SUM-problem}
|
||||
\index{3SUM problem}
|
||||
A more difficult problem is
|
||||
the \key{3SUM-problem} that asks to
|
||||
the \key{3SUM problem} that asks to
|
||||
find \emph{three} numbers in the array
|
||||
such that their sum is $x$.
|
||||
This problem can be solved in $O(n^2)$ time.
|
||||
Can you see how it is possible?
|
||||
Can you see how?
|
||||
|
||||
\section{Nearest smaller elements}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue