• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 17:16
CET 23:16
KST 07:16
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win0Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down23ISSL (IntoTheTV x SOOP SC2 League): Premier7Weekly Cups (October 12-18): 5.0.17 era begins1
StarCraft 2
General
[D] Hacker peak in sc2 ? No more SC2 streamers on team liquid? Liquibets sc2 season 30 Evil Geniuses - shutting down Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win
Tourneys
SC4ALL: II Venue Change Announcement! Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays ISSL (IntoTheTV x SOOP SC2 League): Premier Stellar Fest TWO the Moon (Dec 16-20)
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps Starcraft 2 Advance [D] the control group Simple Questions/Answers
External Content
Mutation # 550 Graveyard Shift The PondCast: SC2 News & Results Mutation # 549 Endless Sparkles Mutation # 548 Shining Bright
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Rollback Netcode in Brood War SC4ALL: II Venue Change Announcement! Ziemie's Starcraft 1 Prequel Campaign 🇺🇦 Ukrainian StarCraft:BroodWar community reborn
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [$1250] International ShieldBattery League KCM Race Survival 2026 Season 4
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Deus Ex 3!? Mobile Legends: Bang Bang Armies of Exigo - YesYes?
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Dating: How's your luck? Trading/Investing Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread
Fan Clubs
Fan Club Resource Thread Reynor Fan Club The Flash Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 13413 users

The Big Programming Thread - Page 934

Forum Index > General Forum
Post a Reply
Prev 1 932 933 934 935 936 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
TheEmulator
Profile Blog Joined July 2010
28104 Posts
Last Edited: 2018-01-03 18:28:52
January 03 2018 18:26 GMT
#18661
On January 03 2018 22:45 tofucake wrote:
Show nested quote +
On January 03 2018 14:01 WarSame wrote:
Does anyone know any good larger/more active programming communities like this? While y'all are great this is unfortunately a single thread on a starcraft forum. Are there any forums(or whatever else) for discussion, code, etc. that are this high quality? SO doesn't count because it's too issue-based.

Only ones I can think of are various subreddits (like /r/programming)

Not a huge reddit fan but some of the programming reddits are fairly solid for sure. Most languages have a subreddit and there's also subs like learnprogramming/cscareerquestions which can be fairly useful if you're new.

I still think most of the good programming communities are on IRC and/or Discord these days though.
Administrator
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 03 2018 23:42 GMT
#18662
I'm looking for all languages, as well as discussion on frameworks, technology, etc. I guess like a nerd site more devote to tech, with a focus on software/mechatronics.

A lot of the individual sub reddits are good, depending on the language, hackernews is also pretty decent, though it's turning a bit redditish for my liking.

I despise /r/programming and loath /r/technology though.


Some of the individuals are good but I'm not interested enough in any one technology(yet) to want to dive that deep.

/r/programming has some good articles, but the discussion is generally not great and the ratio of good articles to bad is low.

/r/technology has a very low quality overall. If there were some higher-quality version of it(like /r/NeutralPolitics is to /r/politics) I think that might be my ideal.

I'll check out hackernews but I heard bad things about it before.

StackOverflow is too issue-focused for what I want.

What are good IRC or Discord channels? I'm assuming there's some Slack channels too?
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
graNite
Profile Blog Joined December 2010
Germany4434 Posts
January 04 2018 11:33 GMT
#18663
The Stackoverflow chats are not that issue based, you can just go there and talk to people.
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
sc-darkness
Profile Joined August 2017
856 Posts
Last Edited: 2018-01-04 17:17:17
January 04 2018 17:12 GMT
#18664
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?
Acrofales
Profile Joined August 2010
Spain18487 Posts
Last Edited: 2018-01-04 18:00:20
January 04 2018 17:58 GMT
#18665
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?

It sounds possible, but horribly inefficient. You can swap the head with the tail, then the head + 1 with tail - 1, etc. etc.

Basically you do this:

a->b->c->d->e
e->b->c->d->a
e->d->c->b->a

all reversed. but it's O(n^2) for simply reversing a list (assuming no auxiliary datastructures). Yuck.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
January 04 2018 18:16 GMT
#18666
On January 05 2018 02:58 Acrofales wrote:
Show nested quote +
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?

It sounds possible, but horribly inefficient. You can swap the head with the tail, then the head + 1 with tail - 1, etc. etc.

Basically you do this:

a->b->c->d->e
e->b->c->d->a
e->d->c->b->a

all reversed. but it's O(n^2) for simply reversing a list (assuming no auxiliary datastructures). Yuck.


Can you change the pointer on node d from e to a with only a singly linked list? The tail node shouldn't know what the previous node is in a singly linked list.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Acrofales
Profile Joined August 2010
Spain18487 Posts
Last Edited: 2018-01-04 18:37:14
January 04 2018 18:27 GMT
#18667
On January 05 2018 03:16 Blitzkrieg0 wrote:
Show nested quote +
On January 05 2018 02:58 Acrofales wrote:
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?

It sounds possible, but horribly inefficient. You can swap the head with the tail, then the head + 1 with tail - 1, etc. etc.

Basically you do this:

a->b->c->d->e
e->b->c->d->a
e->d->c->b->a

all reversed. but it's O(n^2) for simply reversing a list (assuming no auxiliary datastructures). Yuck.


Can you change the pointer on node d from e to a with only a singly linked list? The tail node shouldn't know what the previous node is in a singly linked list.

Swap doesn't change pointer locations. It swaps values. So you swap whatever stuff was at a with whatever stuff was at e. d still points to the same address, but that now has a in it.



int a = 3;
int b = 5;

int* pa = &a;
int* pb = &b;


cout << a << ", " << b;
//output is 3, 5

std::swap(a, b);

cout << a << ", " << b;
//output is 5, 3

cout << *pa << ", " << *pb;
//output is 5, 3



And yeah, obviously there's some other stuff, you obviously can't swap the whole node, but have to unwrap it and only swap whatever content was stored in the node, but I figured that was obvious.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2018-01-04 19:27:54
January 04 2018 19:27 GMT
#18668
On January 05 2018 03:27 Acrofales wrote:
Show nested quote +
On January 05 2018 03:16 Blitzkrieg0 wrote:
On January 05 2018 02:58 Acrofales wrote:
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?

It sounds possible, but horribly inefficient. You can swap the head with the tail, then the head + 1 with tail - 1, etc. etc.

Basically you do this:

a->b->c->d->e
e->b->c->d->a
e->d->c->b->a

all reversed. but it's O(n^2) for simply reversing a list (assuming no auxiliary datastructures). Yuck.


Can you change the pointer on node d from e to a with only a singly linked list? The tail node shouldn't know what the previous node is in a singly linked list.
+ Show Spoiler [snip] +

Swap doesn't change pointer locations. It swaps values. So you swap whatever stuff was at a with whatever stuff was at e. d still points to the same address, but that now has a in it.



int a = 3;
int b = 5;

int* pa = &a;
int* pb = &b;


cout << a << ", " << b;
//output is 3, 5

std::swap(a, b);

cout << a << ", " << b;
//output is 5, 3

cout << *pa << ", " << *pb;
//output is 5, 3



And yeah, obviously there's some other stuff, you obviously can't swap the whole node, but have to unwrap it and only swap whatever content was stored in the node, but I figured that was obvious.


Thank you for the explanation.
I'll always be your shadow and veil your eyes from states of ain soph aur.
sc-darkness
Profile Joined August 2017
856 Posts
Last Edited: 2018-01-04 19:50:37
January 04 2018 19:36 GMT
#18669
Well, it's possible question had something else intended, but what a stupid kind of interview it was. I answered most of questions correctly, fucked up 2-3 questions about algorithms (20-30% of questions). Yet I clarified how I'd attempt to solve the problem, and one of the answers was partial anyway and I'm sure I was on the right path, but they said they weren't happy enough because I struggled with algorithms.

Companies nowadays.. they want everything from a candidate without considering some investment. Sure, my algorithm application might not be great, but what's the problem with training a young candidate with 3 years of experience? They already saw I knew C++, OOP principles, design patterns and data structures.

Also, they didn't like one of my answers which was "I'm not sure about syntax about how I'd solve this with bitwise operations, but I can google it easily". Their answer was "if that was the case, we'd not have jobs". Apparently you have to know everything when you have 3 years of experience.

The question I thought I could solve with bitwise operators was about converting string to number. I know that's in the C++ library already, but question wanted me to implement it instead. I just remember seeing some solutions in the past with bitwise operators, but now I see it's about multiplication by 10. What a useless question anyway. If it's in the C++ library, who cares.
mahrgell
Profile Blog Joined December 2009
Germany3943 Posts
January 04 2018 21:40 GMT
#18670
Looks like they felt they could get someone better.

Not sure the company is the problem here.
sc-darkness
Profile Joined August 2017
856 Posts
Last Edited: 2018-01-04 21:58:47
January 04 2018 21:48 GMT
#18671
Well, you can always get someone better. What's the problem to train someone and offer them slightly lower salary at the beginning? You can't always employ fully experienced people (well, you can but at some point you'll run out of people). In my opinion, that's pretty much profit only and not much investment (full capitalism).

Remember that people need to grow their career after all. They're not born fully educated, fully experienced, etc.
IT industry always complains there aren't enough software developers. How can there be enough if they're not willing to train people when needed? If you enjoy a company but they expect too much, can't you be told to learn a bit while on a lower salary?
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 05 2018 03:51 GMT
#18672
Hurray! I finally put out the 1.0 of my app.

Please feel free to go critique it. You will need 2 Android phones to test the whole transfer flow. Some things I am looking to improve are:

  • security

  • UX, especially when the user has to put in their ethereum address and private key, which is tough on mobile

  • avoiding such a drastic delay when sending a transfer


I am aware the interface is ugly and little bit messed up.

Thanks for whatever feedback you have!
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2018-01-05 05:15:54
January 05 2018 05:06 GMT
#18673
On January 05 2018 06:48 sc-darkness wrote:
Well, you can always get someone better. What's the problem to train someone and offer them slightly lower salary at the beginning? You can't always employ fully experienced people (well, you can but at some point you'll run out of people). In my opinion, that's pretty much profit only and not much investment (full capitalism).

Remember that people need to grow their career after all. They're not born fully educated, fully experienced, etc.
IT industry always complains there aren't enough software developers. How can there be enough if they're not willing to train people when needed? If you enjoy a company but they expect too much, can't you be told to learn a bit while on a lower salary?


It's not that they don't hire less experienced programmers at all, it's that they really want to hire an experienced programmer. Sometimes there's no headcount for less experienced programmers because there's no room on the team for more junior people, i.e. nearing deadlines, no time to dedicate to training new hires, already have several juniors on team.

From an employer's perspective, it's hard to tell when someone's inexperienced but could be great, vs experienced and already decent. Why take the higher risk if you're not looking at hiring juniors?
There is no one like you in the universe.
aRyuujin
Profile Blog Joined January 2011
United States5049 Posts
January 05 2018 06:14 GMT
#18674
On January 04 2018 08:42 WarSame wrote:
I'm looking for all languages, as well as discussion on frameworks, technology, etc. I guess like a nerd site more devote to tech, with a focus on software/mechatronics.

Show nested quote +
A lot of the individual sub reddits are good, depending on the language, hackernews is also pretty decent, though it's turning a bit redditish for my liking.

I despise /r/programming and loath /r/technology though.


Some of the individuals are good but I'm not interested enough in any one technology(yet) to want to dive that deep.

/r/programming has some good articles, but the discussion is generally not great and the ratio of good articles to bad is low.

/r/technology has a very low quality overall. If there were some higher-quality version of it(like /r/NeutralPolitics is to /r/politics) I think that might be my ideal.

I'll check out hackernews but I heard bad things about it before.

StackOverflow is too issue-focused for what I want.

What are good IRC or Discord channels? I'm assuming there's some Slack channels too?


not sure about other languages, but haskell has several email lists and user groups, there are also physical meetups in a lot of places (meetup.com)
can i get my estro logo back pls
Lmui
Profile Joined November 2010
Canada6223 Posts
January 06 2018 00:45 GMT
#18675
On January 05 2018 03:16 Blitzkrieg0 wrote:
Show nested quote +
On January 05 2018 02:58 Acrofales wrote:
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?

It sounds possible, but horribly inefficient. You can swap the head with the tail, then the head + 1 with tail - 1, etc. etc.

Basically you do this:

a->b->c->d->e
e->b->c->d->a
e->d->c->b->a

all reversed. but it's O(n^2) for simply reversing a list (assuming no auxiliary datastructures). Yuck.


Can you change the pointer on node d from e to a with only a singly linked list? The tail node shouldn't know what the previous node is in a singly linked list.


This only applies in the case that the list is circular. If it's not circular, it wouldn't work because e would point to null, instead of a.

If you were allowed another data structure, you could accomplish it in O(n) time by getting an iterating through to get an array of pointers to list items, and swapping only the head +i'th, tail - i'th members.
Lmui
Profile Joined November 2010
Canada6223 Posts
January 06 2018 01:02 GMT
#18676
On January 05 2018 14:06 Blisse wrote:
Show nested quote +
On January 05 2018 06:48 sc-darkness wrote:
Well, you can always get someone better. What's the problem to train someone and offer them slightly lower salary at the beginning? You can't always employ fully experienced people (well, you can but at some point you'll run out of people). In my opinion, that's pretty much profit only and not much investment (full capitalism).

Remember that people need to grow their career after all. They're not born fully educated, fully experienced, etc.
IT industry always complains there aren't enough software developers. How can there be enough if they're not willing to train people when needed? If you enjoy a company but they expect too much, can't you be told to learn a bit while on a lower salary?


It's not that they don't hire less experienced programmers at all, it's that they really want to hire an experienced programmer. Sometimes there's no headcount for less experienced programmers because there's no room on the team for more junior people, i.e. nearing deadlines, no time to dedicate to training new hires, already have several juniors on team.

From an employer's perspective, it's hard to tell when someone's inexperienced but could be great, vs experienced and already decent. Why take the higher risk if you're not looking at hiring juniors?


This is partially why internships/co-ops are so important in school.

I interview people for internships (technical interviews) every 4-8 months as well as the occasional FT when we get headcount. I usually do 6-10 interviews each round.

With co-ops/interns, I'm 90% interested in ability to learn, and think around a problem. Even if they don't know the answer to a problem, I listen to:

1. How they would approach this
2. What resources do they go to to solve the problem?
3. What additiional information do they think they need to solve the problem?
4. Can they pseudo-code something

With an FT hire, even at the junior level, I care far more about experience.

1. Concrete example of when they ran into problems, how they went about resolving them
2. Ability to write mostly correct code (less worried about semi-colons/syntax/method names like insert/add, more on general correctness) in a relevant language (java/c++)
3. Experience with technologies other than just single computer single process application

With someone that we're stuck with for a short period of time, I can take a chance on someone with a lot of enthusiasm. If they ramp up quick, we can offer extensions/FT slots. If not, meh they're only here for 4/8 months.
This is pretty much a permanent junior member of our team that we ramp up every cycle, as far as we can get them, and know that we'll need to spend time developing. In exchange, we've gotten some stars that we bring back on as FT members after they graduate, and they jump pretty much immediately from junior dev to dev.
Thaniri
Profile Blog Joined March 2011
1264 Posts
January 06 2018 06:39 GMT
#18677
Co-ops in Canada are particularly popular because it is government subsidized labour. It is a stroke of governmental brilliance to have this policy. In my city, every tech company hires co-ops, even startups.

Work experience >>>>>>> education in my opinion. I didn't learn to play warcraft/starcraft by reading the manual that comes in the CD box.

dekibeki
Profile Joined June 2011
Australia34 Posts
January 06 2018 07:56 GMT
#18678
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?


we could reverse it by doing something like
v
a->b->c->d
v
a<-b<-c<-d

You're just swapping the links, this can be done in O(n).
I don't use std::swap for my implementation below, but you could fit it in somewhere (squash prev/next into one variable and std::swap it with node->next?)
+ Show Spoiler +


template<typename T>
struct ListNode {
ListNode* next;
T data;
};

/*Takes the start of a singly linked list, returns the new start once it's been reversed*/
template<typename T>
ListNode<T>* reverseList(ListNode<T>* node) {
ListNode<T>* prev = nullptr;
ListNode<T>* next;

while(node) {
next = node->next;
node->next = prev;
prev = node;
node = next;
}
return prev;
}

As before, we travel through the linked list, setting the next pointer to the previous node, then at the end we return the last node, the new head.
Acrofales
Profile Joined August 2010
Spain18487 Posts
Last Edited: 2018-01-06 09:43:37
January 06 2018 09:40 GMT
#18679
On January 06 2018 16:56 dekibeki wrote:
Show nested quote +
On January 05 2018 02:12 sc-darkness wrote:
Could someone confirm if it's possible to reverse order of a singly linked list without using both directions (head and tail)? Just going forward basically. Is that possible without modifying internal data such as node (next/previous pointers) and just using std::swap? This is mostly about C++, but I think the question is generic anyway.

Apparently I failed an interview question about that, so I'm thinking my application of algorithms on the spot isn't so good without Google. Any advice how to get better?


we could reverse it by doing something like
v
a->b->c->d
v
a<-b<-c<-d

You're just swapping the links, this can be done in O(n).
I don't use std::swap for my implementation below, but you could fit it in somewhere (squash prev/next into one variable and std::swap it with node->next?)
+ Show Spoiler +


template<typename T>
struct ListNode {
ListNode* next;
T data;
};

/*Takes the start of a singly linked list, returns the new start once it's been reversed*/
template<typename T>
ListNode<T>* reverseList(ListNode<T>* node) {
ListNode<T>* prev = nullptr;
ListNode<T>* next;

while(node) {
next = node->next;
node->next = prev;
prev = node;
node = next;
}
return prev;
}

As before, we travel through the linked list, setting the next pointer to the previous node, then at the end we return the last node, the new head.

That is the obvious way of reversing a singly linked list in O(n) time. But the assignment was specifically to use swap. I mean, I guess you can always do something like this:


std::swap(prev, node->next);
std::swap(prev, node);


Inside the while loop, but it makes a conceptually simple operation hard to understand for the sake of using std::swap. I guess it's still better than my initial idea of making an O(n^2) algorithm out of the whole thing.

I guess I feel the question was badly phrased. I would ask it in two steps (a) write an algorithm to reverse a singly linked list. (b) use std::swap in this algorithm.

That said, the intent of the question was clear from the start: it's quite clearly to test some basic programming skills in c++. You need to understand pointers and a bit about the standard library. And you need to know how to solve a programming problem. These are all quite basic skills, and the intent is that you make an effort and the interviewer can see how far advanced you are.

E: reread the initial question. It said explicitly not to mess with the next pointers. That's what sent me on the O(n^2) algorithm track. However, now I wonder whether that was in the actual interview question or was sc-darkness interpretation of it.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 06 2018 17:42 GMT
#18680
I don't know anything about std swap, but couldn't you just create an array with length of the linked list, and starting at the end of the array iterate backwards while also iterating the linked list, putting pointers to each node in each array index

then, iterate back through the array from start to finish to change the direction of your linked list. O(n).
Prev 1 932 933 934 935 936 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 12h 45m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nathanias 103
EmSc Tv 13
StarCraft: Brood War
Britney 9247
Shuttle 366
Shinee 35
LuMiX 2
Dota 2
PGG 166
League of Legends
Doublelift3535
JimRising 276
Counter-Strike
apEX2394
zeus359
Super Smash Bros
hungrybox58
Heroes of the Storm
Liquid`Hasu616
Other Games
summit1g5563
gofns3688
Grubby2408
FrodaN873
shahzam410
PiGStarcraft306
Fuzer 197
C9.Mang0177
syndereN166
XaKoH 124
NeuroSwarm62
ViBE44
ZombieGrub33
KnowMe26
Railgan23
JuggernautJason20
Organizations
Other Games
BasetradeTV174
Counter-Strike
PGL89
StarCraft 2
EmSc Tv 13
EmSc2Tv 13
[ Show 18 non-featured ]
StarCraft 2
• Adnapsc2 18
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Laughngamez YouTube
• Migwel
StarCraft: Brood War
• Azhi_Dahaki40
• FirePhoenix8
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV697
League of Legends
• Jankos3361
• Nemesis3257
• Scarra634
Other Games
• imaqtpie784
• Shiphtur264
Upcoming Events
IntoTheTV X SOOP
12h 45m
Reynor vs Solar
ByuN vs SHIN
Clem vs MaxPax
herO vs Rogue
IPSL
18h 45m
WorsT vs nOmaD
Dewalt vs andersOn
AI Arena Tournament
20h 45m
IntoTheTV X SOOP
1d 12h
IPSL
1d 18h
Azhi_Dahaki vs ggnore13
Double vs WIZARD
Replay Cast
2 days
Replay Cast
3 days
Sparkling Tuna Cup
3 days
WardiTV Invitational
3 days
YoungYakov vs Lambo
SHIN vs TBD
Percival vs Shameless
Solar vs TBD
PiGosaur Cup
4 days
[ Show More ]
The PondCast
5 days
KCM Race Survival
5 days
WardiTV Invitational
5 days
Liquipedia Results

Completed

Proleague 2026-11-05
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
Calamity Cup Div. A Season 8
IEM Beijing 2026
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026

Upcoming

Sector 951
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Underdog Cup 2026 Div 2-3
PGL Bucharest 2027
BLAST Bounty Winter 2027
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.