## Software Engineer / Developer Interview Questions

- 0of 0 votes
Given a non-directed, strongly connected graph where the node values are letters of the alphabet, write an algorithm that prints out all possible permutations of strings. What is this called?

For example:

V = A,B,C

Printout

ABC

ACB

BAC

BCA

CAB

CBA

BAC etc.

- 0of 0 votes
Given a sorted integer array, write a method that builds a balanced binary search tree. What is the runtime complexity?

Hint: Recursion.

Follow-up: Non-recursive solution

- 0of 0 votes
Given a list of tuples {x, y, x' } that describe histograms on the X/Y axis, such that X is the X coordinate, Y is the Y coordinate, and X' is the distance from X, write a function that draws the skyline of these tuples.

For example:

{3, 2, 4} , {4,5,3} will give the following points:

{3,0} - trivial

{3,2} - trivial

{4,5} -calculated

{7,0} -if list is done.

You cannot assume that the tuples are sorted. Provide runtime analysis.

- 0of 0 votes
Given a list of integers of size n, write a method to write all permutations the list; do this in O(1) space

Hint: No recursion.

- 1of 1 vote
Given a decimal number, write a function that returns its negabinary (i.e. negative 2-base) representation as a string.

`#!/usr/bin/env python3 assert solution(-15) == '110001' assert solution(2) == '110' assert solution(13) == '11101'`

- 0of 0 votes
I have an array with 60% sorted and 40% unsorted, which algorithm will give fastest accurate sorted output in C? And for Linked list which sorting algorithm suited?

- 0of 0 votes
How can I find factorial of positive integers using structures in C?

- 3of 3 votes
Assume there are 10000 stars in sky, how would you find which star is closest to the earth? in C

- 0of 0 votes
Create a program to compute nth Fibonacci number in O(1) space and faster than O(n) time.

(Target complexity is O(logn)).

- 0of 0 votes
i need to write code that union two nodes from graph G Vi ,Vj

then new node will generated Vm = ViUVj

- 0of 0 votes
Image an airport with the control tower having a constantly rotating radar scanning for airplanes. The radar's coordinates in the 2-d plane are (0,0). The radar has an API: void scan(const Plane &P) that is called periodically whenever the radar detects a plane. You can imagine that the Plane structure has x,y coordinates for that plane. You should fill in the function Scan, such that at any given time you are able to return the 100 closest planes to the tower (0,0).

- 0of 0 votes
Given a tree.

Each node is of type:`public class Node { public IEnumerable<Node> Children { get; set; } }`

Write a function GetAllNodes which returns collection, containing all nodes from given tree. (Given only the root node), i.e.:

`IEnumerable<Node> allNodes = GetAllNodes( rootNode );`

(The task is given in C#, but this is not a restriction, you may use any language you want).

- 0of 0 votes
How do you create your own garbage collector? How do you find whether objects in memory are orphans in order to purge them?

- 1of 1 vote
for given array

`s[] = {5,1,0,4,2,3}`

1) length of array is not given.

2) If length of array is 5 content is guaranteed to be between 0 to 5. There is no repetition of numbers. Sample example for length(s, 3)

- a[3] = 4 , a[4] = 2, a[2] = 0, a[0] = 5, a[5] =3

returns length of 4 .

For given condition write subroutine

int length (s, 3)

- to find the number of steps it takes to find given value - It's a function api - that I was asked to write with the conditions - I cannot change parameters of the function - I have to make sure return value is correct

Additional Condition:

You cannot use any loop statements like for, while and so on -

You cannot use any global or static variables.

You cannot call other routines inside this routine

You cannot modify given function parameters - it stays length (s, n) only

You cannot change original array too

- 1of 1 vote
Google is conducting a contest where they display a special doodle to the user

submitting the billionth query of the day. Design a system to achieve this. (NOTE:

Google has thousands of servers and each query can hit a different server).

Optimise it. How will you handle server failures?

- 0of 0 votes
Implement class Queue with help of only 2 stacks.

i.e.:`class Queue<T>{ private Stack<T> _stack1; private Stack<T> _stack2; // public methods: Enqueue, Dequeue, Peek, Count // private methods, if any. }`

- 0of 0 votes
Implement class Stack with help of only 2 queues,

i.e.:`class Stack<T>{ private Queue<T> _queue1; private Queue<T> _queue2; // public methods: Push, Pop, Peek, Count // private methods, if any. }`

- 0of 0 votes
Asked me to write an API. Then ask:

Consider how the API could support 3rd party applications which need to perform some logic based on the structure and content of a filter in a type-safe manner.

- 0of 0 votes
It is part of a programming exercise.

Input is a combination of arbitrary complex filters. For example:

name = "smith" AND age > 9 OR Not(city = "New York")

It asks for a string representation, including the ability to generate and parse filters from the string representation. (you are not required to implement the string parsing logic since this could take too long)

Hint: give an example of a tree data structure.

- 0of 0 votes
For a given string and dictionary, how many sentences can you make from the string, such that all the words are contained in the dictionary.

// eg: for given string -> "appletablet"

// "apple", "tablet"

// "applet", "able", "t"

// "apple", "table", "t"

// "app", "let", "able", "t"

// "applet", {app, let, apple, t, applet} => 3

// "thing", {"thing"} -> 1

- 2of 2 votes
What is the fastest way to compute cube root?

- 0of 0 votes
The idea is their are "ticket stalls" with a certain number of tickets, say 9. Any ticket they sell is priced at the number of tickets that remain, so first ticket would be $9, second $8 etc...

You're given two lines of data, say:

2 4

1 5

The first row contains two numbers:

The number of stalls

How many tickets are sold

The second line contains a list of how many tickets each stall has initially, so in this case stall 1 has 1 ticket, stall 5 has 5 tickets.

The problem: what is the maximum amount of money you can make selling the given number of tickets?

In this case, you sell four tickets from stall two for a price of 5 + 4 + 3 + 2 = $14

- 2of 2 votes
There is a circular train (the head is connected to the tail) where each car of the train contains a light bulb. Initially, the bulbs are randomly switched on/off.

You need to determine the size of the train (the number of cars)

by going from one car to another and switching the light bulbs

- 2of 2 votes
Given predicted stock prices for next n days for a stock e.g : 10, 30, 42, 15, 20, 50, 10, 25 find the maximum profit that can be made with a single buy-sell transaction. If no profit can be made return 0. In the example buying at 15 and selling at 50 gives maximum profit. Note that the two prices are neither minimum nor maximum in the array.

- 0of 0 votes
design a bit map of 16K bit

get_bit, should get a free bit in this bit map

clear_bit, should clear a bit in this bit map

- 1of 1 vote
write a program to toggle certain bits in a integer.

Eg.

Inputs : int a, int start bit, int num_of_bits

if a is say 11111010110100000

if start = 6

num_of_bits = 4

output should be (starting 6th bit from right, toggle 4 bits)

11111010001000000

- 0of 0 votes
write a program to count the 2 letter words in a sentence. Eg. "I am in love with New York" should return 2 (am and in).

- 0of 0 votes
design routing table using trie

- 0of 0 votes
what are the advantages of IPV6 over IPV4 other than the scale advantage ?

- 0of 0 votes
write a program to find the number when a string is transformed to a palindrome, you can go from higher alphabet to lower alphabet and not the other way:

Example:

to convert "abc" to palindrome, 'c' should be changed to 'a'. output should be 2 ('c' - 'a').