<!DOCTYPE html> <html> <head> <title>Hello, World!</title> <link rel="stylesheet" href="styles.css" /> </head> <body> <div id="main-splitpane-left" class="coding-question__left-pane"><section class="question-view__title-wrapper"><div class="beta-icon-editor beta-desc">BETA</div><span class="question-view__switch-theme__wrapper">Can’t read the text? <button class="ui-btn ui-btn-normal ui-btn-plain btn-as-link question-view__switch-theme"><div class="ui-content align-icon-right"><span class="ui-text" aria-hidden="false">Switch</span></div></button> theme</span><h1 class="question-view__title">1. Optimizing Box Weights (example question)</h1></section><section class="question-view__instruction"><div class="candidate-rich-text"><div id="24i33a0pf0l-instruction"><p>An Amazon Fulfillment Associate has a set of items that need to be packed into two boxes. Given an integer array of the item weights (<code>arr</code>) to be packed, divide the item weights into two subsets, A and B, for packing into the associated boxes, while respecting the following conditions: </p> <p> </p> <div class="ps-content-wrapper-v0"> <ul> <li><span style="font-family:"Whitney SSm A" , "Whitney SSm B" , AvenirNext-Regular , "Segoe UI" , Ubuntu , "Helvetica Neue" , Helvetica , Arial , sans-serif;font-size:1em;font-weight:normal;">The intersection of A and B is null.</span></li> <li><span style="font-family:"Whitney SSm A" , "Whitney SSm B" , AvenirNext-Regular , "Segoe UI" , Ubuntu , "Helvetica Neue" , Helvetica , Arial , sans-serif;font-size:1em;font-weight:normal;">The union A and B is equal to the original array.</span></li> <li><span style="font-family:"Whitney SSm A" , "Whitney SSm B" , AvenirNext-Regular , "Segoe UI" , Ubuntu , "Helvetica Neue" , Helvetica , Arial , sans-serif;font-size:1em;font-weight:normal;">The number of elements in subset A is minimal.</span></li> <li><span style="font-family:"Whitney SSm A" , "Whitney SSm B" , AvenirNext-Regular , "Segoe UI" , Ubuntu , "Helvetica Neue" , Helvetica , Arial , sans-serif;font-size:1em;font-weight:normal;">The sum of A's weights is greater than the sum of B's weights.</span></li> </ul> <p> </p> <p>Return the subset A in increasing order where the sum of A's weights is greater than the sum of B's weights. If more than one subset A exists, return the one with the maximal total weight.</p> <p> </p> <p><strong>Example</strong></p> <p><em>n = 5</em></p> <p><span style="font-family:"Whitney SSm A" , "Whitney SSm B" , AvenirNext-Regular , "Segoe UI" , Ubuntu , "Helvetica Neue" , Helvetica , Arial , sans-serif;font-size:1em;font-weight:normal;"><em>arr = [3, 7, 5, 6, 2]</em></span></p> <p> </p> <p>The 2 subsets in <em>arr</em> that satisfy the conditions for <em>A </em>are<em> [5, 7]</em> and <em> [6, 7]</em> :</p> <ul> <li>A is minimal (size 2)</li> <li>Sum(A) = (5 + 7) = 12 > Sum(B) = (2 + 3 + 6) = 11</li> <li>Sum(A) = (6 + 7) = 13 > Sum(B) = (2 + 3 + 5) = 10</li> <li>The intersection of A and B is null and their union is equal to <em>arr</em>.</li> <li>The subset A where the sum of its weight is maximal is [6, 7].</li> </ul> <p> </p> <p class="section-title"><strong>Function Description</strong></p> <p>Complete the <em>minimalHeaviestSetA</em> function in the editor below.</p> <p> </p> <p><em>minimalHeaviestSetA </em><strong>has the following parameter(s):</strong></p> <p> <em>int arr[]:</em> an integer array of the weights of each item in the set</p> <p> </p> <p><strong>Returns:</strong></p> <p> <b id="docs-internal-guid-50c4b635-9349-999b-5712-a2bba90c0934"><em>int[]</em> : an integer array with the values of subset A</b></p> <p> </p> <p class="section-title"><strong>Constraints</strong></p> <ul> <li><em>1 ≤ n ≤ 10<sup>5 </sup></em></li> <li> <em>1 ≤ arr[i] ≤ 10<sup>5 </sup></em><b><em>(</em>where<em> 0 ≤ i < n)</em></b> </li> </ul> <p> </p> <!-- <StartOfInputFormat> DO NOT REMOVE THIS LINE--> <details><summary class="section-title"><strong>Input Format For Custom Testing</strong></summary> <div class="collapsable-details"> <p dir="ltr"><b>The first line contains an integer, <em>n,</em> denoting the number of elements in the array.</b></p> <p dir="ltr"><b>Each line <em>i</em> of the <em>n</em> subsequent lines contains an integer, which is an element of <em>arr.</em></b></p> <p dir="ltr"> </p> </div> </details> <!-- </StartOfInputFormat> DO NOT REMOVE THIS LINE--> <details><summary class="section-title"><strong>Sample Case 0</strong></summary> <div class="collapsable-details"> <p class="section-title">Sample Input For Custom Testing</p> <pre>STDIN Function ----- -------- <b>6 </b>→ <i> arr</i>[] size n = 6<b> 5 </b>→ <i> arr</i>[] = <b>[5, 3, 2, 4, 1, 2]</b><b> 3 2 4 1 2</b></pre> <p class="section-title">Sample Output</p> <pre>4 5</pre> <p class="section-title">Explanation</p> <p dir="ltr"><b id="docs-internal-guid-30cb3446-934e-0ddb-63fe-13120270e31b"><em>n = 6</em></b></p> <p dir="ltr"><b><em>arr = [5, 3, 2, 4, 1, 2]</em></b></p> <p dir="ltr"> </p> <p>The subset of A that satisfies the conditions is [4, 5] :</p> <ul> <li>A is minimal (size 2)</li> <li>Sum(A) = (4 + 5) = 9 > Sum(B) = (1 + 2 + 2 + 3) = 8</li> <li>The intersection of A and B is null and their union is equal to <em>arr.</em> </li> <li>The subset A with the maximal sum is [4, 5].</li> </ul> <p dir="ltr"> </p> </div> </details> <details><summary class="section-title"><strong>Sample Case 1</strong></summary> <div class="collapsable-details"> <p class="section-title">Sample Input For Custom Testing</p> <pre>STDIN Function ----- -------- <b>5 </b>→ arr[] size n = 5<b> 4 </b>→ arr[] = <b>[4, 2, 5, 1, 6] 2 5 1 6</b></pre> <p class="section-title">Sample Output</p> <pre>5 6</pre> <p class="section-title">Explanation</p> <p dir="ltr"><b id="docs-internal-guid-30cb3446-934e-0ddb-63fe-13120270e31b"><em>n = 5</em></b></p> <p dir="ltr"><b><em>arr = [4, 2, 5, 1, 6]</em></b></p> <p dir="ltr"> </p> <p>The subset of A that satisfies the conditions is [5, 6]:</p> <ul> <li>A is minimal (size 2)</li> <li>Sum(A) = (5 + 6) = 11 > Sum(B) = (1 + 2 + 4) = 7</li> <li>Sum(A) = (4 + 6) = 10 > Sum(B) = (1 + 2 + 5) = 8</li> <li>The intersection of A and B is null and their union is equal to <em>arr</em>.</li> <li>The subset A with the maximal sum is [5, 6].</li> </ul> </div> </details> </div> </div></div></section></div> </body> </html>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML
. You can also specify the stylesheet information in styles.css
tab and scripts information in scripts.js
tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html>
<html>
and ends with </html>
<h1>
to <h6>
where <h1>
is the highest important heading and <h6>
is the least important sub-heading.<p>..</p>
tag.<a>
tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img>
tag, where src
attribute consists of image name.<button>..</button>
tag<ul>
for unordered/bullet list and <ol>
for ordered/number list, and the list items are defined in <li>
.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table>
tag.<tr>
tag<th>
tag<td>
tag<caption>
tag<script>
is the tag used to write scripts in HTML<script src="script.js"></script>