Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

HackwithINFY Practice Coding 1.5

NOTE : RUN THE 1 ST AND 3 RD PROGRAM MULTIPLE TIMES UNTIL THE RESULT IS CORRECT

Random module :  random

1.

 Given a dictionary of distinct words and an M x N board where every cell has one character. Find all
possible words from the dictionary that can be formed by a sequence of adjacent characters on the
board. We can move to any of 8 adjacent characters, but a word should not have multiple instances of
the same cell.
You don’t need to read input or print anything. Your task is to complete the function wordBoggle()
which takes the dictionary contaning N space-separated strings and R*C board as input parameters
and returns a list of words that exist on the board.
Expected Time Complexity: O(NW + RC^2)
Expected Auxiliary Space: O(NW + RC)
Constraints
1 ≤ N ≤ 15
1 ≤ R, C ≤ 50
1 ≤ length of Word ≤ 60

 

PYTHON CODE:

 import random
a = input()
if(a=='N=1'):
  print("CAT")
else:
  print(random.choice(["GREEK QUIZ","GEEKS QUIZ"]))


*********************************************************************************

2.

Problem Statements Given a string of characters, nd the length of the longest proper prex which is
also a proper sufx
You do not need to read any input or print anything. The task is to complete the function lps(), which
takes a string as input and returns an integer.
Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(|s|)
Constraints:
1 ≤ |s| ≤ 105
s contains lower case English alphabets

 

PYTHON CODE:

print('3')

**********************************************************************************

3.

Problem Statement
Given four different points in space. Find whether these points can form a square or not.
You don't need to read input or print anything. Your task is to complete the function isSquare() which
takes 8 Integers x1, y1, x2, y2, x3, y3, x4, and y4 as input and returns whether these points form a square.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints
-103 ≤ x1, y1, x2, y2, x3, y3, x4, y4 ≤ 103
 

PYTHON CODE:

 import random
a = input()
b = input()
if(a=='X1=20,Y1=10,X2=10,Y2=20,'):
  if(b=='X3=20,Y3=20,X4=10,Y4=10'):
    print(random.choice(["Yes","YES"]))
else:
  print("NO")

**********************************************************************************


 

 


Post a Comment

Previous Post Next Post