Professional Documents
Culture Documents
Arrays 1 Aug22
Arrays 1 Aug22
h Assays
problems on
array
folitiattta
arr 10
for int i o i
ang ittle
Point Caroli
en ask I 3 2 6 8 4 8 53
Us
assess 12 3 16 3 3 2 10 83
66
a 553 I 8 8 I 3 is
bo
Obs 2 iterate on I
get the total Oca of
array
man element Co
3 7
final ans 10
logic building
input
11 PSuedo code
int countgreater int arr 3 I
oji
I find the man element
of array
int man arco
Lint it i an itt 9
for mark
Toc nth if Laroli aioli
an man
S.c OCD
inti o ien it t C
for ifCaroli many
Ctt
return as length C
false
stonefalse
A Given a elements check if there exists a
assay
Pair if Such that arofi t arolj K and i j
Note i I are inden value k is given
j
Sum erand
1 10
13 2
true
I I 3 8 83
any I 2 y 5 7 3
K 5
false
a sus I 2 y 3 33
K 8 arr 1 an f 8
4false
arrest I 3 5 2 7 33
kit arr 6 tarry ok
4pm
arcs 43 5 2 75
K 12
0,0 1,0 2,0 3,0 4,0
N J 0,1 1,1 2,1 3,1 4,1
41 2 3 4 0,2 1,2 2,2 3,2 4,2
0,3 1,3 22,3 3,3 7,3
In 0,4 1,4 2,4 13,4 4,4
2 3 41 N l
j start from 9 18
go
till
lay
Efron inden
Li start from 0
go till 2nd lastid
I Pswedo code
bool sum int arr I int k s
agamid
Hashman forcintiagiciastiengthizgitty
sorting winters K C
if arofittarolj
return true
Te 062 J
SC OC
return false I o o m
I Donot remember maths directly
understood
Concept Solved
forget
take time
48mins 3 Boblers
Q Given an Reverse the entire
array array
Note asos itself Should change
en arcs I i n I 2 at 8 is
He
a j a 183 10 8 17 2 6 7 4 1
Bay
an 17 I I b 3 2 8 5 183 reversal
starring
9 8 23 3 g gg
i j
O c 6
1 5
29 4
icj
11 PSuedo code
void reverse int and3 f
int i o
int j Groolength 1
while Ci j L a 3Iters code
How usingtemp
Swap i j
itt
j
FC Ocn
Sec Old
a Given
array
a element and Isi ISI reverse
from
Gi to ed
Note Si ca ee
en arcs a 3 i if i 5 213
ee
i j f 3 4 24 6 9 7 83 103
3 7
4 6
11 PSuedo code
void reverse intarsia inti in
int is Si
int ei
Tec O n je
SC Ole while Ci j L i
How
Swap i j
itt
j
Given
Q a
array element Rotate away from last
to K times
first by google amazon meta
a 263 23 2 I I 8 5 83
k3
potation
8 3 2 a 4 6 93
Isotation 2
49 8 3 2 1 4 63
footations
4 6 98 3 2 1 43
assess hi i i g z it is 3
4 9
foot I
43 4 1 6 9 2 14 7 8 3
120 2
8 3 4 16 9 2 14 73
toots
7 8 3 4 16 9 2 14
12079
419 7 8 3 41 6 9 23
S.c old
6 TC OLD XX OCnt k
Oss 023 I i i 6 5 83
I 9 634 1 2333
46 98 3 2 r y
48 gift i i
assess hi i i g z ii i s 3
LE 8 7 17 9 6 I 4 3
1
Y 7 8 3 4 1 6 92
KM 7 8 3 4 16 9 23
Steps
Reverse entire serene Carr O N D
array
Reverse the k elements reverse arr O KD
Reverse the first
remaining elements reverse att K M 1
I Psuedo code
n a serene Carr O N l
K
If arr length
n a reverse arr O K D
n reverse ax K M l
Tac Oln
Ocn to n to n E o Cn
S c OCD
I th
K am length
asf 23 i i d d g I z
ref I
1C 13
8 3 2 a 4 6 9
76 120 2
9 8 3 2 a 4 6
12073
6 9 8 3 2 a 4
120 9
4 6 9 8 3 2 0
120 5
1 Y 6 9 8 3 2
120 6
2 I 4 6 9 8 3
foot
3 2 I 4 6 9 8
7 31
IF
31 7
0
8 34 5 2
3448
Kt corolength
loop 0cm
10082 Ocn Mash nip a an
10083 OCP Man m nip a
10087 Oca
i j
L ed
away 8 I i 4 6 5 8 31 6983.2
42321 6 9 8 3 2 1
O
6 9 8 4 3 2 1
n 35
Q
for Lint is
icing it 3171
for int
j
2
joy jF2 f
04
8
3
I n o
g
12
15
at
H zu
achy'ands 27
3 80
I
got n
33
36
gg
In jumps
1 73
HI
old jumps
pivot O
Q let i pivot A l
for length l
o itt
IK
if Caldicott Ali B Pivot
Count t
g
pivot i
A length 1
if i o font
pivot t t's
1 A N Dae
is Pivot
2 2 ne Dre
3
i
My M I m i
H
OG
Q int count 0
it 271 i
j
for intine i 0
n
forcinejo jci jtt cane D ne
Count 1
GET F
y beg
sernsgfqq_i sr.t
F 98 1
8
N I i
1 2 4 Az
l
21 y
I do
s
21 and
d log funda 12 8 2 3
to y
a
log 2420222
109264 6
log 80 6 7 866.5
6.2
Logzloo 6 7 6 n
I 2 4 8 16 N
cogan or
H 1
E E g g
He
E 4
U
I 1
2
legals
muzzy as total no often
logy 10825
z or
logan
22
y M dog n
12
N 1 Clog N