Update exam/packet.tex
This commit is contained in:
@@ -143,7 +143,7 @@ Output:
|
||||
\end{comment}
|
||||
\newpage
|
||||
% ========================= Problem 6 =========================
|
||||
\problem{Problem 6(.7): Six Seven}
|
||||
\problem{Problem 6(.7): Sequencing}
|
||||
\textit{Difficulty: Easy}
|
||||
\begin{itemize}
|
||||
You are given a string S composed of only the characters ‘6', ‘7’, ‘A', ‘B', and ‘\#' (without the quotation marks). This string is processed from left to right, and you must maintain a sequence of chracters that changes according to these rules:
|
||||
@@ -237,5 +237,59 @@ Input 3:
|
||||
Output 3:
|
||||
Sixxx sevennn
|
||||
\end{verbatim}
|
||||
|
||||
% ========================= Problem 8 =========================
|
||||
\newpage
|
||||
\problem{Problem 8: Staircase}
|
||||
\textit{Difficulty: Medium}
|
||||
|
||||
There is a staircase with N steps. Each step is labelled with a 6 or a 7. Simon starts at step 1 and wishes to reach the top step (Step N). If a step is labelled with a 6, Simon may go up 1 or 2 steps. If a step is labelled with a 7, Simon can move up exactly 1 step. Your job is to find the total number of distinct ways Simon can reach the top step N, given these rules.
|
||||
|
||||
\inputformat
|
||||
\begin{itemize}
|
||||
\item The first line consists an integer N($1 \leq N \leq 10^5$), the number of steps
|
||||
\item The second line will consist of N integers, the label of each step (either 6 or 7)
|
||||
\end{itemize}
|
||||
|
||||
\outputformat
|
||||
\begin{itemize}
|
||||
\item Output the number of distinct ways Simon can reach the top step N. Note that Simon starts at step 1.
|
||||
\end{itemize}
|
||||
|
||||
\examples
|
||||
\begin{verbatim}
|
||||
Input 1:
|
||||
5
|
||||
66766
|
||||
|
||||
Output 1:
|
||||
3
|
||||
|
||||
Explanation 1:
|
||||
Case 1: Step 1->2->3->4->5
|
||||
Case 2: Step 1->2->4->5
|
||||
Case 3: Step 1->3->4->5
|
||||
|
||||
Input 2:
|
||||
3
|
||||
677
|
||||
|
||||
Output 2:
|
||||
2
|
||||
|
||||
Explanation 2:
|
||||
Case 1: 1->2->3
|
||||
Case 2: 1->3
|
||||
|
||||
Input 3:
|
||||
1
|
||||
6
|
||||
|
||||
Output 3:
|
||||
1
|
||||
|
||||
Explanation 3:
|
||||
There is only one way to get to the top (which Simon is already at).
|
||||
\end{verbatim}
|
||||
\end{document}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user