Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

-mport J ava. 10.

• ;
_m ort j ava .uti l.*;"
- - .. .. - ... -.. .

// Read only regi on star t


UserMain Code
{

pub lic int [] hash _and _sto re(i nt [] inpu tl){


// Read only regi on end
// Wri te code her& ••.
Inte ger []ou tput =new Inte ger- [inp utl . leng th];
int ele= 8i
int inde x=~ _
-in-c dilf= ll;in t loe= 8~
t bool ean ~uc =tru e,;
f_ = _f ~h j2~ 1 £etRJ:Fnef l ntrj eet ['2J;
f~ ~ . ~ , .1:(1 nf 1=1JkiCIJ1PU1:I: .. 1eng th;f++ )=:=:[

bode .. ~esY lts :ve:. ~~ .. I Comp ile& 1E

1-650-924-9221 ~ +9f 8047190902


in·t inde ~.=B;
. 10~ =8·:
int dig~ e- int
,) ~

boo lean s~c= tru~ ;


Obj ect[ ] tem p~neW' Obj eoti (:Z] ;
for ( int i=0; i<in put 1.le ngt nJu i++ ){
ele= ihp ut:t (i];
inde x=e le% 18;
if ( out put [ i hd ex] ~t:::: nul l) {
1
1

I out put [ind ex] ~el e~


}
else {
di,g =ele %10 ;
loc= ele/ '1 0; 1

I
tem p= reHa slH1( o'u tp ~t ., dig_. loc ) i
111
1
1

suc =( bo.Al~.an ) ('tefflpC1]? ~ l'oc:=( int )tem p[e] ;


if (suc,)i{
j out pµt [loc ]~e le ;

ode Res ults You r Tes tcas e

1 1-65 0-924-922 1 +91 804 71 ~0902


outp ut
}
else {
dig= ele% 10;
loc= ele/1 0;
temp =reH ash{ outp ut,di g,loc );
suc= ( bool ean )(tem p[l] );loc =( int )tem p[0] ;
i-f (suc ){
I outp ut[lo c]=e le;
}
else{
int orig inal Ele= ele;
ele/= 10; I
dig= ele% 10;
loc= ele;
whil e (ele! =0){
I temp =reH ash( outp ut,d ig,lo c);

Cade Resu lts Your Testc ase

+1-6 50-9 24-9 221 ~ - +91 8047 1909 02 ~


~ ele;
output[loc]
}
e l s e{
o r i g i n a l E le~ele;
int
ele/==10;
d i g == e l e % 1 0 ;
loc =ele;
8){
while (ele! =
p = r e Ha s h ( o u t p u t , d ig,loc); ----= 0 ] ; -i
t e m n t ) t e m p [ = -=== - ~ - -
1];1oc=( i
_ _ _ _ =
" - = = =t~
= .. .. ..
o l e a n ) t e m ~ [
s=u c = ( b o
t" " = ~ ·=
==
l: = = = t= = = =
~ = - -
i-f (suc){
t-
- =f= - - = =
=t-a::=
l= = = t = =
c ] = o r i g i n a l Ele;
output[lo I
break ;
}
ele/=10;
d i g = e l ,e% 1 0
;
C o m p il e &
}
e
Y o u r T e s tc a s
o ,d e R e s u lt s
902
~ - +9i1 8 0 4 7 1 9 0
1 . ·• ~ ~ ~
·-
11 il
1
I

I I

'I
I

I I
Compile & TE

ode Results

1-650-9 24 -9 221 rfJ',~ (;,, ~~1 ({>))1 (I


-~ .
E:
5 }
6 ·if ( ele==0) {
7 for ( int j=loc;j<(loc+10);j++){
8 ,i nt: pos=j%10.;
9 if (output(pos] ==null){
10 output[pos)=originalEle;
fl break ;
12 }
13 }
}
14
fS }
f6 }
} I
f7
"8 int [] res=new int [10];
r far (int j=0;j<output.length;j++){
i9
;e
I
res[j]=output[j];
Ll l-
Compile & Tes'
Code Results Your Testcase

+ 1-650-924 -9221 ~ - +91 8047190902 d!::i

Insert Oe\ete
PrtScr
2
3
4
5 }
6 }
7 }
8 int [] res=new int [10];
9 f or ( int j=0 ; j <output . length;j++){
0 I res [ j ] =output[j];
1 }
f2 return res;
r3 }
!>4 public Obj ect[] reHash(Integer[] output, int dig, int l oc ){
I

fS Object []result=new Obj,ect[2]; I


f6 if (dig%2 == 0){
57
l
rs Q
I loc=Math.abs(loc-d i g)%10;
if (output[loc]==nu l l )
r~c::111 +r1 , =+""' 'tll •
Compile & Tes·
Code Results Your Testcase

+1 -650-924-922 1 ~ +91 8047190902 ;&:

Insert Oe\ete
PrtScr
res
j_ }
·1 return res;
}
public Obj ect[] reHash(Integer[] output, int dig, int loc){
Object []res ult=new Object[2];
iF(dig%2 == 0){
loc=Math . abs (loc - dig)%10;
if (out put[loc] ==null)
I result[l] =true ;
else
j result[l]=false ;
}
else{
1 loc=(loc+dig)%10;
if (output[loc]==nu ll)
result[l]=true ;
Compile & Tes
Code Results Your Testcase

+ 1-650-924-9221 ~ +9 1 804 7190902 =

Oe\ete PgUt>
PrtScr Insert
F11 F12
pub1ic Object
Object []result=new Object[2];
if(dig%2 == 0){
loc=Math.abs(loc-dig}%10;
ir (output[loc]==null}
I result[l]=true;
else
I result[l]=false ;
2 }
V3 else{
r4 loc=(loc+dig)%10;
~5 if (output[loc]==null)
~6 1 result[l]=true ;
r7 else I
rs I result[l]=false ;
9 }
e r-esult[0]=loc;
Compile & Test
Code Results Your Testcase

+ 1-650-924-9221 ~ - +91 804 7190902 ~

/&I I ',\fJ (l>}} 11 ENG 1


IN S

Insert De\ete
F12 PrtScr
F11
r - if(output[loc]==null)
I resu_lt[l]=true; .
else
I resuit[l]=false ;
}
else{
loc=(loc+dig)%10;
if (output[loc]==null)
l result[l]=true ;
else
I result[l)=false ;
}
result[0]=loc; I
return result;

}
4 }
Compile & Test
Code Results Your Testcase

+1-650-924-9221 ~ +91 8047190902 =

Insert Oe\ete
PrtScr
F11

You might also like