Trilogy OA Questions
Trilogy OA Questions
Trilogy OA Questions
DESC
maln.cpp
You're creating a new 1 int solution
programming language with
some exciting new featurest Any
2
programming 3 )
language cacheck if two strings are 4
HISTORY
you'd like yours to be able to check if
matching, but
they're almost
matching More specifically, we'lil say two strings are
RULES
almost matching if they're equal in length and of
all
their corresponding characters are the
same except
for one. For example, "cat" and
"bat" are
README almost matching, but "cat" and "dog are not
For the sake of efficiency,
youre planning on testing
he feature by using a single
string andcomparing its
SETTINGs substrings, Givena string s and an integer k
your task is to find the number of pairs of
of
substrings
that are almost matching but differ at
their
Kh character (0-based), it's
necessary that the
length of both sutbstrings exceeds k
(otherwise the
strings wouldn't have a kh character),
Also note that substrings are
determined by their
indices, so there could potentially be
multiple
instances of the same word. For example, in the
word " ingratiating" the substring
ing" TESTS
IMOR CUSTOM TESTS
app.codesignal.com/test/waxzikpWkhiWXtBb/question/K36bi4EgomKn
ACK TO GUESTIONS
=3
<
maln.cppP
sC .("ab" , "ac" )- i =4, j - 5, 1= 2. n
1 int solution (s t
3
3}
STORY Input/Output
" [execution time limit] 0.5 seconds (cpp)
RULES
"(memory limit) 1GB
" (input) string s
README
Astring consisting only of lowercase Engiish
letters.
SETTINGS
Guaranteed constraints
1ss.length s 200
Guaranteed constraints:
0sk <s.length
- [output] integer
Codewriting main.cpp
SC 1 vector<int> sc
Problem Description 2
3 }
Welcome to the magical world of Mario's adventure 4
rORY
where Mario is standing on platform 0 and needs to
reach platform A+1. But oh no, there's a wide river
that's A units wide blocking his way. Mario can't
ULES
walk
on water, but he's got an amazing
ability - he can
jump up to B units at a time, either forward or
backward.
EADME I
On the river, there are
various-sized wooden
platforms floating on the river just like in Mario's
SETTINGs games. In total there are M platforms and their sizes
are stored in an integer array C. Mario can
move
these platforms around, but he can't change their
order or let them overlap. Note that he should first
move the platforms and then start his journey. Help
Mario cross the river and reach platform A+1.
[0, 1,0, 2, 2, 0, 3] 4
3}
RY
Output2:
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0]
ES
Example Explanation
ADME
For Input 1:
For Input2:
HORE TESTS
app.codesignal.com/test/ w9ak21 VKnIVWAt On/wikk4tA/SZKKm
BACK TO QUESTIONS
Input/Output
-jexecution time limit) 0.5 seconds (cpp)
-memory limit) 1GB
-input array.string crypt
Aray of three non-empty strings
anly uppercase Engish letters
containing
Guaranteed constraints
LScypt[l-lengths 35
- outpug integer
Codewriting
SC
main.cpp
Acryptarithm is a 1 int solution
mathematical puzzle where the 2
goal is to find the
correspondence between letters 3}
and digits such that the given 4
TORY arithmetic equation
consisting of letters holds true.
Given a cryptarithm as an array of
strings crypt
ULES
count the number of its valid I
solutions.
The solution is valid if each
letter represents a
EADME different digit, and the leading digit of any
number is not zero. multi-digit
crypt has the following structure:
[wordl,
SETTINGS word2, word3], which stands for the
word1l
word2 = word3
cryptarithm.
Example
" For crypt ["SEND", "MORE",
the output should be
"MONEY"1
solution (crypt) 1, because there is
only one solution to this cryptarithm:
O0,M1, 2E5N6,
Y
D
7R8,and S=9 (95674 108S
1 MORE TESTS CUSTOHTEST
Example main.cpp
ESC 1 ec
. For
SETTINGS
For
field [.
AISTORY
blocks are denoted by ' and empty cells are
denoted by
RULES
and you throw a block into the first or
the second row
from the top, it will end up like this:
README
SETTINGS
Your task is to
calculate the minimum and the
maximum number of moves required to fill the first
colurnn of the board with blocks.
Example
" For
FieldI,a,
TESTS
CURTOTEST
O Codewriting
main.cpp
SC
You are given a rectangular board 1 Fectorci
divided into a 2
uniform grid (square cells). Some cells of the board 3 }
are occupied with blocks,
TORY and others are empty. You
are trying to add more and
more blocks to the board,
and your task is to fill the first
column with them.
Your can add a block to the
ULES field in the following way:
first, youchoose the row index, then
you throw the
new block into the
chosen row from the left. The
README
block appears in the leftmost cell of
the row and
starts moving to the right, until it
block or the end of the row. reaches another
When that happens, the
SETTINGS
block starts falling down until in
block or the last row. reaches another
For example, if the board
looks like this
Output Format
RULES Return an integer array representing the
answer.
Example Input
README
Input 1:
A=7
SETTINGs B=2
C(1,2, 1]
Input 2 :
A 10
B5
C (21
Example Output
Outputs
TESTS
TO QUESTIONS
letters.
3 }
Guaranteed constraints
1ss.length s 200
Guaranteed constraints
0sk <s.length
ADME
TTINGS
The amount of different pairs as described
above.
RY "ati" sbstrings).
Example
ES
For s "abacaba" andk= 1,the output should
be
solution (5, k) 8
ADME
Using i and j to represent the start and end
indices of the first substrings, and 1 and m to
fepresent the indices of the second substring, the 8
TTINGS
pairs are:
""aca"
"aba" ) - i = 2, j= 4, 1-0,
m21
" ("aca"aba")- i= 2. j - 4, 1-4,
m6
Question 2 of 4 Submitted v
malnJava
1 int [) solution (int a, int b, int[] ) {
ASUS Vivobook