what will be the output if the sum is 4 ?
On Sun, Aug 12, 2012 at 11:22 PM, harsha wrote:
> A smart 3 year old Sandeep knows counting. But he doesn't know how to read
> and write properly. He has learnt 1, 2 and 3 but thinks that 4 is another
> way to write 1.
> So when given any number with 1,
have look at :
http://codingways.blogspot.ca/2012/08/hanoi-tower-in-c.html
On Sun, Aug 12, 2012 at 11:27 PM, Siddharth Malhotra wrote:
> Please help me out with Hanoi problem of n disks.
> Algorithm and code preferably in C++.
>
> http://en.wikipedia.org/wiki/Tower_of_Hanoi
>
>
> --
> You recei
bool is_lucky(int x){
int pos=x;
inr count=2;
while(countwrote:
> @daksh paaji kya baat hai thanks for the solution. aap har jagah hai :P
>
>
> On Sat, Aug 4, 2012 at 12:21 AM, Daksh Talwar wrote:
>
>> maintain a bool array of size of limit of int
>> store true for lucky numbers
>> and then cross
its base 26 but little modification in code ...
@shiv - nice solution .
char Carr[26]={a,b,c...z}
i=0;
int arr[];
do
{
arrr[i++]=n%26;
n=(n/26)-1;
}
while(n) ;
for(int i=n-1;i>=0;i--)
cout< wrote:
> No. It's not base 26 at all. Given input 26, your code will return ba, but
> the result should be
Solution for - all number appears two time except three number which
appears 1 or 3 times.
array indexing method is used to solve in O(n) time complexity and O(1).
first find min - O(n)
then in for loop 1 to n
a[abs(a[i])-min]=-a[abs(a[i])-min];
then find the -ve number in array
then answer will
use simple recursive function to solve -
int countfun(int sum ){
int i;
int count;
int total=0;
if (sum==0)
return 1;
for(i=1;i<=3;i++){
if (sum-i<0)
break;
count=countfun(sum-i);
if(i==1)
count*=2;
total+=count;
}
return total;
}
On Sun, Aug 12, 2012 at 11:22 PM, harsha wrote:
> A smart 3 ye
http://marathoncode.blogspot.com.br/2012/08/truque-paridade-magica.html
http://marathoncode.blogspot.com.br/2012/08/matematica-na-babilonia.html
http://marathoncode.blogspot.com.br/2012/08/a-beleza-da-matematica.html
http://marathoncode.blogspot.com.br/2012/08/jogo-das-cartas.html
http://marathonco
I guess O(1) extra space means constant extra space.
In that case, you can have a hash map ( or a bool array) and then switch
b/w true and false for every occurence.
All of those which havent been switched twice , are the result.
On Sun, Aug 12, 2012 at 9:16 PM, g4ur4v wrote:
>
> --
> You recei
if you meant to calculate the E[x] for [HT,TH,TT]. It can be solvable but
very lengthy/boring.
I shall give you an example which should help you.
Let E[X] = x be the expected no. of coin flips to get [HT]
1) if first flip is a tail, we have wasted one flip hence. E[X1] = 1/2*(1+x)
2) if first fl
Does the pattern comes in this way? HT,TH,TT or HT(X)TH(X)TT ??
Let me know.
--
Amitesh
On Sat, Aug 11, 2012 at 11:24 PM, Piyush wrote:
> How can I find the expected number of tosses , required to obtain a
> {HT,TH,TT} , by using random variables??
>
> On Friday, December 31, 2010 8:27:46
Please help me out with Hanoi problem of n disc problem.
Algorithm and code preferably in C++.
http://en.wikipedia.org/wiki/Tower_of_Hanoi
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googleg
Given N points in 2D plane, you have to calculate the number of right
triangles, with their shorter sides parallel to the coordinate axis, that
can be formed using these N points.
Input/OutputYou don't have to read or write anything from/to stdin and
stdout respectively. Use the template code
Please help me out with Hanoi problem of n disks.
Algorithm and code preferably in C++.
http://en.wikipedia.org/wiki/Tower_of_Hanoi
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.c
A smart 3 year old Sandeep knows counting. But he doesn't know how to read
and write properly. He has learnt 1, 2 and 3 but thinks that 4 is another
way to write 1.
So when given any number with 1, 2, 3 & 4, he tries to sum up their digits
as follows :
213 = 2 + 1 + 3 = 6
33 = 3 + 3 = 6
1
@venkat +1
On Sun, Aug 12, 2012 at 9:09 PM, ~*~VICKY~*~ wrote:
> @Arun: This approach is constant time once the array is build for any
> queries that follows. :) You know sum for all possible rectangles in the
> given 2d array thats makes it better than computing sum for each input.
> Hope it mak
a small question, if matrix has 'r' rows and 'c' columns, how many
different rectangles can be there for this problem ?
Space Complexity = O( (r*r)*(c*c) )
On Sat, Aug 11, 2012 at 7:10 PM, Srividhya wrote:
> hi all:)
>
> The coordinates of a rectangle will be specified. there is a matrix of
> in
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/La5cAv04gqQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this gro
@Arun: This approach is constant time once the array is build for any
queries that follows. :) You know sum for all possible rectangles in the
given 2d array thats makes it better than computing sum for each input.
Hope it makes sense
On Sun, Aug 12, 2012 at 9:07 PM, ~*~VICKY~*~ wrote:
> Fine, th
Fine, the basic idea of using dp here is sum of each rectangle is a
dependent sub problem. So when u find sum for smaller rectangle we can use
it to compute sum of bigger rectangle with new coordinates added to
previous small rectangle. So u can compute the sum array by using this
formula
sum[i][j
@Vicky, but it is better than ur sol, ur sol take space of O(n2) if u r not
modifying the same array, and also to build the sum array it take O(n2)
time. And Can u elaborate how u make this sum array?
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks"
@vicky
can yo explain the logic behind the 'Sum Array' computation (if possible
elaborately )?
On Sun, Aug 12, 2012 at 8:19 PM, ~*~VICKY~*~ wrote:
> Lets build the array for the example you gave.
>
> i/p:
>
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
>
> (x1,y1) = (0,0)
> (x2,y2) = (1,2)
> sumArray
> 0 1
@Arun: How do you claim your solution to be constant time? :P
On Sun, Aug 12, 2012 at 8:46 PM, Arun Kindra wrote:
> *within
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.
*within
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group
You can traverse in spiral order and add each element with the specified
co-ordinate.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email
Lets build the array for the example you gave.
i/p:
0 1 2 3
4 5 6 7
8 9 10 11
(x1,y1) = (0,0)
(x2,y2) = (1,2)
sumArray
0 1 23
4 10 18 28
12 27 45 66
(will take O(n^2) to build above array)
So now when you get coordinates as input, you can calc the sum by
Ans = sumArray[x2][y2] -
@ Vicky
Can yo explain with an illustration ?
On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ wrote:
> May be you can consider creating a 2d array to pre process and store all
> the rectangle sums as a dependent subproblem, the sum of larger rect will
> be currValuesAdded+OldRectSum. So when you g
say yo have 3*4 matrix...
0 1 2 3
4 5 6 7
8 9 10 11
if the co-ordinates are (0,0),(0,2),(1,0),(1,2)
the o/p should be 0+1+2+4+5+6
On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar wrote:
> Sum of the integers meaning? Do you mind giving an example test case?
>
> regards.
>
> On Sat, Aug 11, 2012
Divide 2D array into 4 parts. Compute sum of each partition and get max
value from the four of them. For all possible partitions get min value of
such max values computed.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discuss
Thanx hassan for correcting me. I think there must be some DP solution for
this problem.
On Sun, Aug 12, 2012 at 5:26 PM, Hassan Monfared wrote:
> Mr. Navin !
> the main question is not about finding max path for one permutation among
> the n! permutations!
> please read the question again and jo
Mr. Navin !
the main question is not about finding max path for one permutation among
the n! permutations!
please read the question again and join us for solving the main problem
On Sun, Aug 12, 2012 at 4:19 PM, Navin Kumar wrote:
> We can solve using Dynamic programming..
> Take n*2 matrix for s
We can solve using Dynamic programming..
Take n*2 matrix for storing sum. Let A be original matrix and matrix M hold
sum. Let M[i, j] contains max sum upto i th row and j th column.
recursion will be as follows:
M[i, j] = max(M[i - 1, j], M[i, j-1]) + A[i, j]
By above formula fill whole M matrix
DP can help us to find max path,
I couldn't find out any specific solution for complexity less than O(n!)
but as an initial Idea, I think some kind of sorting rows or
modified Floyd-Warshal algorithm may help us.please discuss If you have any
Idea for challenge the problem.
On Sun, Aug 12, 2012 a
@vicky i l keep it in mind nxt tym onwardss.. thnku
On Sun, Aug 12, 2012 at 2:01 PM, ~*~VICKY~*~ wrote:
> Always share code using ideone like sites or discuss the algo approach.
> Attaching code isn't the best idea is my personal feeling.
>
> Regards,
> Vicky
>
>
> On Sun, Aug 12, 2012 at 12:44 A
Yes, and all the values are positive integers.
For example
1 2
3 4
5 6
Maximum path in this matrix is 15,
Another permutation of the same matrix
5 6
1 2
3 4
Maximum path in this matrix is 17,
We want the minimum value among these maximum paths.
On 8/12/12, MeHdi KaZemI wrote:
> On 8/12/12, Has
On 8/12/12, Hassan Monfared wrote:
> do we sum all cell values when we step over them ?
>
> On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI
> wrote:
>
>> Hi there,
>> There is a integer Matrix with dimensions n*2, If you want to go from
>> (1,1) to (n,2) and you are allowed just to go down or right
do we sum all cell values when we step over them ?
On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI wrote:
> Hi there,
> There is a integer Matrix with dimensions n*2, If you want to go from
> (1,1) to (n,2) and you are allowed just to go down or right, what's
> the maximum value you can get? Alrig
Always share code using ideone like sites or discuss the algo approach.
Attaching code isn't the best idea is my personal feeling.
Regards,
Vicky
On Sun, Aug 12, 2012 at 12:44 AM, Ankit Singh wrote:
> if i am correctly understand the problem den i hv attchd the solution..
>
>
> On Sun, Aug 12, 2
Hi there,
There is a integer Matrix with dimensions n*2, If you want to go from
(1,1) to (n,2) and you are allowed just to go down or right, what's
the maximum value you can get? Alright this is easy, but we want to
consider all the permutations of rows of the matrix which is n!, find
this maximum
The property seems ambiguous ..
On Sat, Aug 11, 2012 at 5:22 PM, payal gupta wrote:
> Given the start and an ending integer as user input, generate all integers
> with the following property.
> Example : 123 , 1+2 = 3 , valid number
> 121224 12+12 = 24 , valid number
> 1235 1+2 = 3 , 2+3 = 5 ,
1. Print the zig-zag traversal of a BST.
2. There is a language Googley. There are two global registers X and Y both
of whom have the character 'A' stored in them. There are only two commands
in the language.
i) next
ii) print
next increments the character in the X register. After reaching 'Z', ag
Hi,
Section A - objective type 10 technical questions in OS,Algorithms,DS,C.
each carries one mark. no negative marks
Section B - coding 2 questions
first was very simple
second - spiral level order traversal of a BST
--
You received this message because you are subscribed to the Google Groups
smbody plz post cisco written Qs
On Thu, Aug 9, 2012 at 12:29 PM, Abhi wrote:
> Hi Guys,I have Cisco & Goldman Sachs placement exams next week.
> If anyone has appeared for cisco or Goldman Sachs recentlyplz post
> some of the questions asked by them.
> It would really be of great help for m
if i am correctly understand the problem den i hv attchd the solution..
On Sun, Aug 12, 2012 at 12:40 AM, Ankit Singh wrote:
> is output is depend on no of digits in a number like 123 example for odd
> no of digits and 121224 example for even digits???
>
> can you make it clear pls??
>
> On Sat,
You are given n white balls in the beginning. Each day you pick up a ball
randomly, color it red and put it back. If it is already colored, you
simply put it back. This operation is performed for 'd' days. What is the
probability that after d days you will have greater than 'k' balls colored?
--
Can anyone pls share some real world examples for each datastructure nd
sorting algos..
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/cxuwSiqTuuIJ.
To po
is output is depend on no of digits in a number like 123 example for odd no
of digits and 121224 example for even digits???
can you make it clear pls??
On Sat, Aug 11, 2012 at 5:22 PM, payal gupta wrote:
> Given the start and an ending integer as user input, generate all integers
> with the fol
one Q is zig zag traversal in a tree nd d other one is like - A new
language is defined called "googley " and it has two register only 'X' and
'Y' and only two commands are avialable "next" and "print" each one has
some specific function (i don't remember now) and now u are given a string
and u h
47 matches
Mail list logo