I attended a programming competition(it has ended now). I don't know why my solution is giving WA, I read the editorial, saw other people solution but unable to find a flaw in my solution. Obviously I am missing somewhere. Please help! Question Link
I have a code that generates all of the possible combinations of 4 integers between 0 and 36. This will be 37^4 numbers = 1874161. My code is written in MATLAB: i=0; for a = 0:36 for b= 0:36 for c = 0:36 for d = 0:36 i=i+1; combination(i,:) = [a,b,c,
I need to group addresses given their distances. Let's say I have a list of 8 addresses. 5 in NYC and 3 in New Jersey. From those 5 in NYC 3 are close to the MET and 2 to the WTC. Those 3 in NJ would form one group, those close to the MET another and
Say we have two english texts T1 and T2 (disjoint no overlap ) cut out from a larger text T. Is there a way to figure out that T1 and T2 came from a single larger text? For example , newspaper layout is in multi column text. Given two column of text
I have a grid (an NSArray of CGPoints)where I want to layout some objects at points based on some constraints. This is what I know: How big the grid is The number of objects that have to be laid out on the grid, at a point The minimum distance betwee
Everyone knows of the cracker barrel triangle peg solitare game. You take one peg and jump it over another into an empty hole and the goal is to have only one peg left. In my code for the game board object I have a function sCpeg(int a, int b) which
I have a non directed graph that is connected. I want to make it bi-connected by adding minimum number of edges. How can i do it? I tried searching online for this particular algorithm and also tried thinking myself without success. Please help me un
I have a set of objects (rectangles having 4 vertices of (X,Y) each) draw on a map using OpenGL ES. I would want to implement way finding between each of them. For example I have rectangles A,B,C,D,E Structure: A[Vertex(X,Y),Vertex(X,Y),Vertex(X,Y),V
I am trying to implement a randomly generated maze using Prim's algorithm. I want my maze to look like this: however the mazes that I am generating from my program look like this: I'm currently stuck on correctly implementing the steps highlighted in
I am constructing a btree from some data. Once I construct the btree (i.e. insert all the elements) I no longer insert or remove elements. However the resulting btree is not optimal in a sense that if I can have n maximum elements per node very frequ
Problem I came across is as follows: We have n tasks with l_i and w_i being completion time and weight of task i. Come up with an algorithm that minimizes sum for all i of f_i * w_i where f_i is time when task i was finished. If for example some task
I recently saw this question on a programming challenge, and I'd like to know which well-known CS algorithm this resembles. I implemented a crude solution. I know there must be a better way to do it, but I'm not sure of the terms to search for. It se
I have a very large dataset (500 Million) of documents and want to cluster all documents according to their content. What would be the best way to approach this? I tried using k-means but it does not seem suitable because it needs all documents at on
Because we know that the integers representing a vertex can take values in [0,...,|V|-1] range, we can use counting sort in order to sort each entry of the adjacency list in O(V) time. Since we have V lists to sort, that would give us a O(V^2) time a
It's proven that, the Karmarkar-Karp's differencing algorithm always performs better than greedy for 2-way partitioning problems, i.e. partitioning set of n integers to 2 subsets with equal sums. Can this be extended to k-way partitioning as well? If
Say I have three robots connected as a triangle, how do I manage to avoid obstacles in working space? I'm thinking about using A*, but I got problem that it works for one robots but when comes to 3 robots it will cause collision. I'm really new to ro
Suppose, there is an e-commerce site with at least a million products falling in different categories, but no tags or categories are specified. The only information available on each products are the title string of the product, an image and a descri
I was asked this during a Google Interview. We are given a string consisting of letters- F,L,R. - which is the instruction a robot follows F- goes forward by one step. L-turn left. R- turn right. String length can be upto 2500 characters. The string
I'm looking for a sorting algorithm that honors a min and max range for each element1. The problem domain is a recommendations engine that combines a set of business rules (the restrictions) with a recommendation score (the value). If we have a recom
Being given parameters C and M, help decrypt a list of encrypted integers. The former parameter is used for generating {a_n} and {s_n} sequences, defined as follows: a_1 = a_2 = 1 forall n>=1: a_(n+2) = C * a_(n+1) + a_n forall n: s_n = a_1 + a_2