FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DSnAlgoUsingJS/DataStructures/Queue/queueFromStack.js at master · aashishGitHub/DSnAlgoUsingJS · GitHub
aashishGitHub
/
DSnAlgoUsingJS
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DSnAlgoUsingJS
/
DataStructures
/
Queue
/
queueFromStack.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (43 loc) · 1.1 KB
Breadcrumbs
DSnAlgoUsingJS
/
DataStructures
/
Queue
/
queueFromStack.js
Copy path
File metadata and controls
53 lines (43 loc) · 1.1 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
var
Stack
=
require
(
'../Stack/stack'
)
;
class
QueueFromStack
{
constructor
(
)
{
this
.
first
=
new
Stack
(
)
;
this
.
second
=
new
Stack
(
)
;
}
add
(
item
)
{
this
.
first
.
push
(
item
)
;
}
remove
(
)
{
while
(
this
.
first
.
peek
(
)
)
{
this
.
second
.
push
(
this
.
first
.
pop
(
)
)
;
}
const
record
=
this
.
second
.
pop
(
)
;
while
(
this
.
second
.
peek
(
)
)
{
this
.
first
.
push
(
this
.
second
.
pop
(
)
)
;
}
return
record
;
}
peek
(
)
{
while
(
this
.
first
.
peek
(
)
)
{
this
.
second
.
push
(
this
.
first
.
pop
(
)
)
;
}
const
record
=
this
.
second
.
peek
(
)
;
while
(
this
.
second
.
peek
(
)
)
{
this
.
first
.
push
(
this
.
second
.
pop
(
)
)
;
}
return
record
;
}
}
function
checkQueueFromStack
(
)
{
var
qfrmstack
=
new
QueueFromStack
(
)
;
qfrmstack
.
add
(
1
)
qfrmstack
.
add
(
{
name
:
'jitendra'
}
)
;
qfrmstack
.
add
(
"Hello"
)
;
console
.
log
(
qfrmstack
)
;
console
.
log
(
"Peek method"
)
;
console
.
log
(
qfrmstack
.
peek
(
)
)
;
qfrmstack
.
remove
(
)
;
console
.
log
(
"After 1 item remove"
)
;
console
.
log
(
qfrmstack
)
;
}
checkQueueFromStack
(
)
;
Back
|
FazBrowse Home
|
New Git URL