FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaProgramming/HackerRank/FiftyFive.java at patch-1 · subham500071430/JavaProgramming · GitHub
subham500071430
/
JavaProgramming
Public
forked from
karterhhgg/JavaProgramming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaProgramming
/
HackerRank
/
FiftyFive.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (33 loc) · 1015 Bytes
Breadcrumbs
JavaProgramming
/
HackerRank
/
FiftyFive.java
Copy path
File metadata and controls
41 lines (33 loc) · 1015 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package
HackerRank
;
import
java
.
util
.*;
class
Student
{}
class
Rockstar
{ }
class
Hacker
{}
public
class
FiftyFive
{
static
String
count
(
ArrayList
mylist
){
int
a
=
0
,
b
=
0
,
c
=
0
;
for
(
int
i
=
0
;
i
<
mylist
.
size
();
i
++){
Object
element
=
mylist
.
get
(
i
);
if
(
element
instanceof
Student
)
a
++;
if
(
element
instanceof
Rockstar
)
b
++;
if
(
element
instanceof
Hacker
)
c
++;
}
String
ret
=
Integer
.
toString
(
a
)+
" "
+
Integer
.
toString
(
b
)+
" "
+
Integer
.
toString
(
c
);
return
ret
;
}
public
static
void
main
(
String
[]
args
){
ArrayList
mylist
=
new
ArrayList
();
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
t
=
sc
.
nextInt
();
for
(
int
i
=
0
;
i
<
t
;
i
++){
String
s
=
sc
.
next
();
if
(
s
.
equals
(
"Student"
))
mylist
.
add
(
new
Student
());
if
(
s
.
equals
(
"Rockstar"
))
mylist
.
add
(
new
Rockstar
());
if
(
s
.
equals
(
"Hacker"
))
mylist
.
add
(
new
Hacker
());
}
System
.
out
.
println
(
count
(
mylist
));
}
}
Back
|
FazBrowse Home
|
New Git URL