Account name:
Password
(OpenID?)
(Forgot it?)
Remember Me
You're viewing
aklepatc
's journal
Create a Dreamwidth Account
Learn More
Interest
Region
Site and Account
FAQ
Email
Reload page in style:
site
light
aklepatc
Strange Container
Strange Container
May
.
8th
,
2024
01:34 pm
aklepatc
Code a data structure with 2 operations: push() and popMostFrequent().
Most of the meat is in the comments/discussion below.
Flat
|
Top-Level Comments Only
no subject
Date:
2024-05-09 07:42 am (UTC)
From:
sassa_nf
Good point about clearing the reference. But the order may matter.
Eg
v, c.L[j], c.L[j][0] = c.L[j][0], c.L[j][1:], nil
c.L[j][0] on the left - does that refer to the c.L[j] before or after assignment of c.L[j][1:] to it?
no subject
Date:
2024-05-09 12:36 pm (UTC)
From:
aklepatc
AFAIU the order doesn't matter.
These assignments work like they do in SQL update. Everything to the left of "=" is "after" the change and everything to the right is "before".
If course, I could write a quick test and/or even dig up a link to the relevant place in the spec. Please forgive me for being too lazy.
Edited (Clarification )
Date:
2024-05-09 01:00 pm (UTC)
25 comments
Reply
Flat
|
Top-Level Comments Only
Profile
aklepatc
Recent Entries
Archive
Reading
Tags
Memories
Profile
May
2024
S
M
T
W
T
F
S
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
Most Popular Tags
algorithm
-
1 use
coding interview
-
2 uses
go
-
4 uses
golang
-
4 uses
Page Summary
sassa_nf
-
(no subject)
Style Credit
Style:
Neutral Good
for
Practicality
by
timeasmymeasure
Expand Cut Tags
No cut tags
Page generated Jun. 16th, 2025 03:55 pm
Powered by
Dreamwidth Studios
no subject
Date: 2024-05-09 07:42 am (UTC)Eg
v, c.L[j], c.L[j][0] = c.L[j][0], c.L[j][1:], nil
c.L[j][0] on the left - does that refer to the c.L[j] before or after assignment of c.L[j][1:] to it?
no subject
Date: 2024-05-09 12:36 pm (UTC)These assignments work like they do in SQL update. Everything to the left of "=" is "after" the change and everything to the right is "before".
If course, I could write a quick test and/or even dig up a link to the relevant place in the spec. Please forgive me for being too lazy.