Technology

Tag Archives

Archive of posts published in the category: Interview
May
4

Top 30 Programming questions asked in Interview

LinkedList Programming Interview Questions

A linked list is another important data structure after array and String. It actually compliments array and whatever you cannot do with an array, you can do with a linked list.

For example, the array needs contiguous memory to store objects but the linked list doesn’t need that. It’s difficult to add and remove elements in an array because you need to shift existing elements but that is very easy with a linked list, as you just need to change the pointer to accommodate them.

But, nothing is free in this world. While linked list provides all these functionalities but the cost of that you lose the ability to search elements in constant time with index. Searching and element require traversing linked list, which means examining all nodes, thus cost around O(n) time.


14) How do you find middle element of a linked list in a

Read More
Apr
4

Programming Interview Questions + Help Getting Job Offers


Writing programming interview questions hasn’t made me rich yet … so I might give up and start trading Apple stocks all day instead.

First, I wanna know how much money I could have made yesterday if I’d been trading Apple stocks all day.

So I grabbed Apple’s stock prices from yesterday and put them in a list called stock_prices, where:

  • The indices are the time (in minutes) past trade opening time, which was 9:30am local time.
  • The values are the price (in US dollars) of one share of Apple stock at that time.

So if the stock cost $500 at 10:30am, that means stock_prices[60] = 500.

Write an efficient function that takes stock_prices and returns the best profit I could have made from one purchase and one sale of one share of Apple stock yesterday.

For example:

stock_prices = [10, 7, 5, 8, 11, 9]
get_max_profit(stock_prices)
# Returns

Read More