You are on page 1of 21

Today's content

h Assays
problems on
array

you didn't come this


far only to come this far
11Quick Recap into an
int and new int 53
and

folitiattta
arr 10

ar f i arr 5 and out


ofbou
11 Point all the
assay
elements

void Point an int C art


int n arr length

for int i o i
ang ittle
Point Caroli

Private chat reply for any Question


Public chat Any doubt
a Given a
assay elements Count
no
of elements
having atleast I element greater than itself

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

Obst we donot need to count the man elements

Obs 2 iterate on I
get the total Oca of
array
man element Co

final ans Carr length C


are o I 5 I 488 8
U man 8

3 7
final ans 10

DSA understand question

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

void Rotate int arc int K f


if KkK arr
Kt
lengthy
arr length

n a serene Carr O N l
K
If arr length
n a reverse arr O K D
n reverse ax K M l

void reverse int and I int si inteill


int is Si
int ei
je
while Ci j L
How
Swap i j

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

Out k value serve the


ofarryour
multiple length
of
arr length K
7 13 6
13 7

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

Total time 0 mtnt


Complexity a
Ptg
H H
Ocn Ocd
0 man Can n P Q

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

You might also like