Documentation for 0931d530ae

This commit is contained in:
github-actions
2023-01-22 19:44:10 +00:00
parent a448f64699
commit b48f6e8671
2457 changed files with 9513 additions and 8691 deletions

View File

@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: dynamic_programming/abbreviation.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
@@ -129,32 +129,32 @@ Namespaces</h2></td></tr>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:add60b8858720bf217df22d992d0fefaa"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d73/abbreviation_8cpp.html#add60b8858720bf217df22d992d0fefaa">dynamic_programming::abbreviation::abbreviation_recursion</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; bool &gt; &gt; *memo, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; bool &gt; &gt; *visited, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;str, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;result, uint32_t str_idx=0, uint32_t result_idx=0)</td></tr>
<tr class="memdesc:add60b8858720bf217df22d992d0fefaa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Recursive Dynamic Programming function. <a href="../../d7/d73/abbreviation_8cpp.html#add60b8858720bf217df22d992d0fefaa">More...</a><br /></td></tr>
<tr class="memdesc:add60b8858720bf217df22d992d0fefaa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Recursive Dynamic Programming function. <br /></td></tr>
<tr class="separator:add60b8858720bf217df22d992d0fefaa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af53b2f647bee9c5b75ef8dd9ef685dc8"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d73/abbreviation_8cpp.html#af53b2f647bee9c5b75ef8dd9ef685dc8">dynamic_programming::abbreviation::abbreviation</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;str, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;result)</td></tr>
<tr class="memdesc:af53b2f647bee9c5b75ef8dd9ef685dc8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Iterative Dynamic Programming function. <a href="../../d7/d73/abbreviation_8cpp.html#af53b2f647bee9c5b75ef8dd9ef685dc8">More...</a><br /></td></tr>
<tr class="memdesc:af53b2f647bee9c5b75ef8dd9ef685dc8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Iterative Dynamic Programming function. <br /></td></tr>
<tr class="separator:af53b2f647bee9c5b75ef8dd9ef685dc8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d73/abbreviation_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Self test-implementations. <a href="../../d7/d73/abbreviation_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Self test-implementations. <br /></td></tr>
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d73/abbreviation_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <a href="../../d7/d73/abbreviation_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <br /></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Implementation of <a href="https://www.hackerrank.com/challenges/abbr/problem" target="_blank">Abbrievation</a> </p>
<p >Given two strings, <code>a</code> and <code>b</code>, determine if it's possible to make <code>a</code> equal to <code>b</code> You can perform the following operations on the string <code>a</code>:</p><ol type="1">
<div class="textblock"><p>Implementation of <a href="https://www.hackerrank.com/challenges/abbr/problem" target="_blank">Abbrievation</a> </p>
<p>Given two strings, <code>a</code> and <code>b</code>, determine if it's possible to make <code>a</code> equal to <code>b</code> You can perform the following operations on the string <code>a</code>:</p><ol type="1">
<li>Capitalize zero or more of <code>a</code>'s lowercase letters.</li>
<li>Delete all of the remaining lowercase letters in <code>a</code>.</li>
</ol>
<h3><a class="anchor" id="autotoc_md68"></a>
Algorithm</h3>
<p >The idea is in the problem statement itself: iterate through characters of string <code>a</code> and <code>b</code> (for character indexes <code>i</code> and <code>j</code> respectively):</p><ol type="1">
<p>The idea is in the problem statement itself: iterate through characters of string <code>a</code> and <code>b</code> (for character indexes <code>i</code> and <code>j</code> respectively):</p><ol type="1">
<li>If <code>a[i]</code> and <code>b[j]</code> are equal, then move to next position</li>
<li>If <code>a[i]</code> is lowercase of <code>b[j]</code>, then explore two possibilities: a. Capitalize <code>a[i]</code> or b. Skip <code>a[i]</code></li>
<li>If the <code>a[i]</code> is not uppercase, just discard that character, else return <code>false</code></li>
</ol>
<p >Time Complexity: (O(|a|*|b|)) where <code>|a|</code> =&gt; length of string <code>a</code> </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/AshishYUO" target="_blank">Ashish Daulatabad</a> </dd></dl>
<p>Time Complexity: (O(|a|*|b|)) where <code>|a|</code> =&gt; length of string <code>a</code> </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/AshishYUO" target="_blank">Ashish Daulatabad</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="af53b2f647bee9c5b75ef8dd9ef685dc8" name="af53b2f647bee9c5b75ef8dd9ef685dc8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af53b2f647bee9c5b75ef8dd9ef685dc8">&#9670;&#160;</a></span>abbreviation()</h2>
@@ -183,7 +183,7 @@ Algorithm</h3>
</div><div class="memdoc">
<p>Iterative Dynamic Programming function. </p>
<p >Returns whether <code>s</code> can be converted to <code>t</code> with following rules: a. Capitalize zero or more of s's lowercase letters from string <code>s</code> b. remove all other lowercase letters from string <code>s</code> Note: The transition states for iterative is similar to recursive as well </p><dl class="params"><dt>Parameters</dt><dd>
<p>Returns whether <code>s</code> can be converted to <code>t</code> with following rules: a. Capitalize zero or more of s's lowercase letters from string <code>s</code> b. remove all other lowercase letters from string <code>s</code> Note: The transition states for iterative is similar to recursive as well </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">str</td><td>given string, which might not be abbreivated </td></tr>
<tr><td class="paramname">result</td><td>resultant abbreivated string </td></tr>
@@ -283,7 +283,7 @@ Here is the call graph for this function:</div>
</div><div class="memdoc">
<p>Recursive Dynamic Programming function. </p>
<p >Returns whether <code>s</code> can be converted to <code>t</code> with following rules: a. Capitalize zero or more of a's lowercase letters from string <code>s</code> b. remove all other lowercase letters from string <code>s</code> </p><dl class="params"><dt>Parameters</dt><dd>
<p>Returns whether <code>s</code> can be converted to <code>t</code> with following rules: a. Capitalize zero or more of a's lowercase letters from string <code>s</code> b. remove all other lowercase letters from string <code>s</code> </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">memo</td><td>To store the result </td></tr>
<tr><td class="paramname">visited</td><td>boolean to check if the result is already computed </td></tr>
@@ -297,7 +297,7 @@ Here is the call graph for this function:</div>
<dl class="section return"><dt>Returns</dt><dd><code>false</code> if string <code>str</code> cannot be converted to <code>result</code> </dd>
<dd>
<code>true</code> if string <code>str</code> can be converted to <code>result</code> </dd></dl>
<p ><code>(str[i] == result[j])</code>: if str char at position i is equal to <code>result</code> char at position j, then s character is a capitalized one, move on to next character <code>str[i] - 32 == result[j]</code>: if <code>str[i]</code> character is lowercase of <code>result[j]</code> then explore two possibilites:</p><ol type="1">
<p><code>(str[i] == result[j])</code>: if str char at position i is equal to <code>result</code> char at position j, then s character is a capitalized one, move on to next character <code>str[i] - 32 == result[j]</code>: if <code>str[i]</code> character is lowercase of <code>result[j]</code> then explore two possibilites:</p><ol type="1">
<li>convert it to capitalized letter and move both to next pointer <code>(i + 1, j + 1)</code></li>
<li>Discard the character <code>(str[i])</code> and move to next char <code>(i + 1, j)</code></li>
</ol>
@@ -463,7 +463,7 @@ Here is the call graph for this function:</div>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_8a20dd5bfd5341a725342bf72b6b686f.html">dynamic_programming</a></li><li class="navelem"><a class="el" href="../../d7/d73/abbreviation_8cpp.html">abbreviation.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
</ul>
</div>
</body>