interview-questions

Is cinterviews.com useful for Preparation of Microsoft interview

Please suggest a good website or books for my microsoft interview soon ,One of my Friend suggested cinterviews.com for the interview .............Suggestions pleaseeeeeee ...

Algorithm to count the number of valid blocks in a permutation

Possible Duplicate: Finding sorted sub-sequences in a permutation Given an array A which holds a permutation of 1,2,...,n. A sub-block A[i..j] of an array A is called a valid block if all the numbers appearing in A[i..j] are consecutive numbers (may not be in order). Given an array A= [ 7 3 4 1 2 6 5 8] the valid blocks ar...

Solving the array sum problem using iterators and testing for equality only

While getting ready for interviews, I decided to code the classic "Find if there are two elements in an array that sum up to a given number" question using iterator logic, so that it can be generalized to other containers than vector. Here's my function so far // Search given container for two elements with given sum. // If two such e...

Looking for practical(with computer) web client side exams (javascript, css)

Hi, I looking for practical(with computer) web client side exams (javascript, css) because I have 3 hours exam with javascript + css without internet only notepad+browser. I dont know if i will able to use JQUERY, I should prepare for use only regular javascript. (If you know good books or tutorial its may helps too). Edit: my ideas f...

Interview Question

I was recently asked a weird question in an interview here it is; Private Function sorttable (ByVal dt As DataTable, ByVal sorttype$, ByVal sort_direction$) As DataTable Dim dv As DataView Dim dt2 As DataTable dt2 = dt.Clone dt2.Merge(dt) dv = dt2.DefaultView dv.Sort = so...

What can be said about this java class?

I was asked this question : I was not able to answer - Any answers here? What can be said about a java class which has 1000 lines of code , with 1-n methods having 100 lines and n+1 to m methods having 200 lines of code? I thought, Classes should be okay to have 1000 lines of code and methods are also okay to have 100-200 lines of code...

What's harder, synchronizing 2 threads or 1000 threads?

On Paul Tyma's presentation, I found an interview question: What's harder, synchronizing 2 threads or synchronizing 1000 threads? From my perspective, of course synchronizing 1000 threads is harder, but I can't think of a good reasons for that beside 'of course'. But since it's interview question, may be I'm wrong (interview questi...

C# Linked List, Tracks Head + Tail with APIs InsertAfter + Remove. See any flaws or optimizations?

Another data structure I wrote under interview conditions. It is essentially a generic linked list that tracks the head and tail of the list (probably just for academic exercise, in RL life you'd just use List). Does anyone see any possible flaws or optimizations? using System; using System.Collections.Generic; using System.Linq; using ...

Find the middle element in merged arrays in O(logn)

Okay. The problem comes as below: We have two sorted arrays of the same size n. Let's call the array a and b. How to find the middle element in an sorted array mered by a and b? Example: n = 4 a = [1, 2, 3, 4] b = [3, 4, 5, 6] merged = [1, 2, 3, 3, 4, 4, 5, 6] mid_element = merged[(0 + merged.length - 1) / 2] = merged[3] = 3 Mor...

how to find that is there any loop exist in the link list using two pointers?

Possible Duplicate: How to determine if a linked list has a cycle using only two memory locations. hello i have been asked in an interview that how can i find a loop exists in a link list using only two pointers. i have done the following: 1) find the center of the link list each time 2) by iterating this at the end both th...

Learn more about how .NET works

I just had a quick phone interview. The interviewer asked me a few questions like: How does C# work? What is the CLR and what does it do? What is C# code converted to? Other than the CLR question (for which I gave a very vague answer), I didn't know the answers. There were a few others related to .NET that I don't remember, but I did...

Flattening a doubly linked list with child lists - optimizations, feedback, possible modifications

Attached is a quick program written under interview conditions that is designed to flatten a doubly linked list with child links. I was wondering what folks thought and if there were some optimizations (or possibly another way of doing things) you could point out that I could learn from. Code is below - Test7 is the test of the flattenin...

Is there a unicode character that looks like an ascii one (but isn't equal)?

I'm wanting to write an pre-interview question (for java, but that's not important) that has a different answer if you look at it vs if you copy-paste it and run it so that we can check if people actually do the problem manually. To do this, I'm trying to find a unicode character that will look the same as an ascii character on-screen ...

Check if a number is divisible by 3

Not sure if it's a duplicate. But I need to find whether a number is divisible by 3 without using %, / or *. The hint given was to use atoi() function. Any idea how to do it? ...

Determine how much time does a webpage take to load on user's machine

I want to measure the user perceived experience of web page loading. It is not sufficient to measure the time between receiving request and sending the response. Because that would be the server response time. The user's experience would depend on network latency and his bandwidth in addition to server response time. Any idea? The web p...

modified depth first traversal of tree

I got this question in an interview with amazon. I was asked to perform a depth first traversal of a tree, without using recursion or stack. I could use a parent pointer for each node, as a part of the structure, but nothing else other than that.(for ex, a "visited" variable" or anything). Please suggest me an algorithm. ...

insert, delete, max in O(1)

Can someone tell me which data structure supports insert/delete/maximum operation in O(1) ? Thanks Ram ...

Find the median from a stream of integers

Given an unsorted sequence of integers that flows into your program as a stream. The integers are too many to fit into memory. Imagine there is a function: int getNext() throws NoSuchElementException; It returns the next integer from the stream. Write a function to find the median. Solve the problem in O(n). Any ideas? Hint ...

Generate a message out of cutout magazine characters (interview question)

This problem comes out of the dynamic programming chapter in The Algorithm Deisgn Manual by Skiena. Give an algorithm to determine whether you can generate a given string by pasting cutouts from a magazine. You are given a function that will identify the character and its position on the reverse side of the page for any given charac...

Question regarding dequeues and testing

Hello guys, I am preparing for an interview and I came across these questions. Can some one please help how to solve these questions. Imagine you've 2D system which is just testing whether 2 rectangles are in collision state or not, and you supposed to make a program which takes the code of this system from its developers and test it ...