Skip to content

Commit dbbf95f

Browse files
committed
mock test
1 parent 5551867 commit dbbf95f

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

Mock Test/1.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// IMPORT LIBRARY PACKAGES NEEDED BY YOUR PROGRAM
2+
// SOME FUNCTIONALITY WITHIN A PACKAGE MAY BE RESTRICTED
3+
// DEFINE ANY FUNCTION NEEDED
4+
// FUNCTION SIGNATURE BEGINS, THIS FUNCTION IS REQUIRED
5+
```
6+
function cellCompete(states, days)
7+
{
8+
let ar = []
9+
while(days--){
10+
for(var i=0;i<states.length;i++){
11+
if(i===0){
12+
a=0;
13+
}else{
14+
a=states[i-1];
15+
}
16+
if(i===states.length -1){
17+
b=0;
18+
}else{
19+
b=states[i+1];
20+
}
21+
ar[i] = a ^ b;
22+
}
23+
states = ar;
24+
ar = [];
25+
}
26+
return states;
27+
28+
}
29+
```
30+
// Eight houses, represented as cells, are arranged in a straight line. Each day every cell competes with its adjacent cells (neighbors). An integer value of 1 represents an active cell and a value of 0 represents an inactive cell. If the neighbors on both the sides of a cell are either active or inactive, the cell becomes inactive on the next day; otherwise the cell becomes active. The two cells on each end have a single adjacent cell, so assume that the unoccupied space on the opposite side is an inactive cell. Even after updating the cell state, consider its previous state when updating the state of other cells. The state information of all cells should be updated simultaneously.
31+
32+
<div ng-if="data.isUserTestCase === 0" ng-bind-html="data.testCases.content" class="ng-binding ng-scope"><b>Testcase 1:</b><br><b>Input:</b><br><pre>[1, 0, 0, 0, 0, 1, 0, 0], 1</pre><br><b>Expected Return Value:</b><br><pre>0 1 0 0 1 0 1 0</pre><br><hr><b>Testcase 2:</b><br><b>Input:</b><br><pre>[1, 1, 1, 0, 1, 1, 1, 1], 2</pre><br><b>Expected Return Value:</b><br><pre>0 0 0 0 0 1 1 0</pre></div>

Mock Test/2.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
// IMPORT LIBRARY PACKAGES NEEDED BY YOUR PROGRAM
3+
// SOME FUNCTIONALITY WITHIN A PACKAGE MAY BE RESTRICTED
4+
// DEFINE ANY FUNCTION NEEDED
5+
// FUNCTION SIGNATURE BEGINS, THIS FUNCTION IS REQUIRED
6+
```
7+
function gcd(a,b) {
8+
if(b === 0) {
9+
return a;
10+
}
11+
return gcd(b, a%b)
12+
}
13+
function generalizedGCD(num, arr)
14+
{
15+
let f = arr[num-1];
16+
17+
for(let i=num-2;i>=0;i--) {
18+
f = gcd(f,arr[i]);
19+
}
20+
return f;
21+
}
22+
// FUNCTION SIGNATURE ENDS
23+
```
24+
<div class="tabData" ng-show="data.currentTab == 0">
25+
<span ng-bind-html="data.directions" class="direction_light_automata ng-binding"><p>The current selected programming language is <strong>JavaScript</strong>. We emphasize the submission of a fully working code over partially correct but efficient code. Once Test is <strong>submitted</strong>, you cannot review this problem again. You can use <em>console.log</em> to debug your code. We use <strong>NodeJS 10.13</strong> to evaluate your code.</p></span>
26+
<br><br>
27+
<div compile="data.questionStatement"><p class="ng-scope">The greatest common divisor (GCD), also called highest common factor (HCF) of N numbers is the largest positive integer that divides all numbers without giving a remainder.<br><br>Write an algorithm to determine the GCD of N positive integers.</p><p class="ng-scope"><strong>Input</strong><br>The input to the function/method consists of two arguments -&nbsp;<br><em>num</em>, an integer representing the number of positive integers (N).&nbsp;<br><em>arr</em>, a list of positive integers.</p>
28+
<p class="ng-scope"><strong>Output</strong><br>Return an integer representing the GCD of the given positive integers.<br><em><br></em><strong>Example<br></strong><span style="font-weight: 400;">Input:<br></span><em><span style="font-weight: 400;">num</span></em><span style="font-weight: 400;">&nbsp;= 5&nbsp;<br></span><em><span style="font-weight: 400;">arr = </span></em><span style="font-weight: 400;">[2, 4, 6, 8, 10]</span></p>
29+
<p class="ng-scope"><span style="font-weight: 400;">Output:<br></span>2</p>
30+
<p class="ng-scope"><span style="font-weight: 400;">Explanation:<br></span>The largest positive integer that divides all the positive integers 2, 4, 6, 8, 10 without a remainder is 2. <br>So, the output is 2.</p></div>
31+
<!-- ngIf: data.externalUrl -->
32+
</div>

0 commit comments

Comments
 (0)