Live data from Hacker News

Data Structures and Algorithms Problems

techiedelight.com

1–10 of 12 posts

Re: Data Structures and Algorithms Problems

#2
One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.):

The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language specific patterns, but when you advertise the site as a coding interview helper I think that the solution code should reflect that which should be written in an actual interview.

Re: Data Structures and Algorithms Problems

#3
post #2

One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.): The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language sp…

Here's refined list using STL if you like -

http://www.techiedelight.com/data-structures-and-algorithms-...

Re: Data Structures and Algorithms Problems

#4
post #2

One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.): The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language sp…

So you prefer to use std::array over C arrays?

Re: Data Structures and Algorithms Problems

#5
post #4
post #2

One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.): The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language sp…

So you prefer to use std::array over C arrays?

std::vector

What do you think std:array are?

Re: Data Structures and Algorithms Problems

#6
post #4

Earlier quoted context omitted.

So you prefer to use std::array over C arrays?

std::vector What do you think std:array are?

std::array is stack allocated array with known size compile time. std::vector is dynamically allocated array (on heap).

So C array equivalent = std::array, not std::vector.

Re: Data Structures and Algorithms Problems

#7
post #4

Earlier quoted context omitted.

So you prefer to use std::array over C arrays?

std::vector What do you think std:array are?

I know, just a class version of the C-array but std::vectors has lower performance. I believe that std::array or C array are good enough for problems with non-dynamic input.

Re: Data Structures and Algorithms Problems

#8
post #6

Earlier quoted context omitted.

std::vector What do you think std:array are?

std::array is stack allocated array with known size compile time. std::vector is dynamically allocated array (on heap). So C array equivalent = std::array, not std::vector.

The point of the parent was to write C++ code the C++ way. Most arrays in real programs should be std::vector.

Imitating C arrays with std::array is the perfect example of bastardized C/C++ code.

Re: Data Structures and Algorithms Problems

#9
post #2

One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.): The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language sp…

> If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew.

Or they've spent a lot of time in embedded systems development. Many of us write rather C-ish C++ because of the limitations of older compilers and the age of the code bases.

Re: Data Structures and Algorithms Problems

#10
post #2

One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.): The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language sp…

C++ is a large language that can be used in many different ways. People adopt a subset that is sensible for them. If you are interviewing C++ programmers, you should be aware of it.
Post reply on HN