Use bitwise hashmap.
On Thu, Jan 30, 2014 at 8:46 PM, Don dondod...@gmail.com wrote:
No. If you start at any number in a sequence it will find the entire
sequence. There is no need to start again at some other number in that
sequence.
Don
On Wednesday, January 29, 2014 12:19:21 AM
Maintain the invaraint : i + j = k -1
if B[j-1] A[i] B[j], then A[i] must be the kth smallest
else if A[i-1] B[j] A[i], then B[j] must be the kth smallest
If the above conditions are not satisfied, subdivide the arrays.
On Thu, Jun 13, 2013 at 1:41 PM, sourabh jain wsour...@gmail.com
Lets suppose there is a UTF8 encoding scheme. You have to check if a string
is valid UTF8 or not. Just read the below given description.
UTF-8 is a variable-length encoding of letters or runes. If the most
significant bit of the first byte is 0, the letter is 1 byte long.
Otherwise, its length is
struct node
{
int data;
struct node* left;
struct node* right;
};
struct node* newNode(int );
/* Function to find least comman ancestor of n1 and n2 */
int leastCommanAncestor(struct node* root, int n1, int n2)
{
/* If we have reached a leaf node then LCA doesn't exist
If
: = 9 * 1 + 8 Number/2 = 8.5
So, its neither floor(n/2) +- 1, nor ceil(n/2) +- 1
On Wed, May 29, 2013 at 2:19 PM, Ankit Sambyal ankitsam...@gmail.com
wrote:
Hi Nikhil,
Highest remainder can't be floor(n/2) - 1.
If n = 11, highest remainder would be 5 when it is divided by 6
Hi Nikhil,
Highest remainder can't be floor(n/2) - 1.
If n = 11, highest remainder would be 5 when it is divided by 6, but your
formula gives 4.
On Mon, May 27, 2013 at 8:16 PM, Nikhil Kumar niksingha...@gmail.comwrote:
Since we need to divide so the quotient should be at least 1, and we need
Are these n+1 elements range from 1 to n+1 ?
On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote:
I was asked this in recent amazon onsite interview and asked o write code
Given an Array of integers . N elements occur k times and one element
occurs b times, in other words
You have to make a package library which will do the calculation of
(a^b)mod(c), where a, b, c are very large size of 1 digits. (^- power).
Design a data structure for the numbers' storage and suggest what functions
will you be providing to user with them. Also mention the advantages of
using
@sagar : What is the best answer for this question ??
--
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
void delExtraSpaces (char *Str)
{
int Pntr = 0;
int Dest = 0;
int flag=0;
while (Str [Pntr])
{
if (Str [Pntr] != ' ')
{
Str [Dest++] = Str [Pntr];
flag=0;
}
else if(Str[Ptr]==' ' flag==1)
Str [Dest++] = Str [Pntr];
else
flag=1;
Pntr++;
}
Str [Pntr] = '/0';
}
--
Guys sorry for posting the buggy code . Here is the working code :
void delExtraSpaces (char Str[])
{
int Pntr = 0;
int Dest = 0;
int flag=0;
while (Str[Pntr]!='\0')
{
if (Str[Pntr] != ' ')
{
Str[Dest++] = Str[Pntr];
flag=0;
}
else if(Str[Pntr]==' ' flag==0)
{
Str[Dest++] =
@kunal, anuj : step 2 of my algo takes O(n^2). So how can the TC be O(nlogn)
--
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
Ques 1:
Let l1 and l2 be the 2 lists.
Step 1 : Reverse l1 O(n)
Step 2 : Compare l1 and l2 by comparing each node and traversing
ahead.--O(n)
Step 3: Reverse l1 -O(n)
Ques 2:
Let cur be the node of the linked list which is to be
its because void pointer is incremented by 1, when we do k++
whereas integer pointer is incremented by 4, when we do j++
--
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
The typecasting tells the compiler that the void pointer is now pointing to
an integer and when we use this pointer to access the integer it takes value
from 4 bytes. But when we try to increment that pointer, it will point to
the next byte. Try taking k as pointer to double instead of void, u
Given an array of characters, change the array to something as shown in the
following example.
Given : ddbbccae
O/P : 2d4a2b2c1a1e
Do it in the most efficient manner both in terms of time and space ...
--
You received this message because you are subscribed to the Google Groups
Algorithm
@shady : I think there is a catch in that approach. Plz post ur code
--
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
@raghavan: ur approach uses O(n) space
--
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
@sagar: for abcd, ur pgm gives abcd. I was trying a pgm which gives
1a1b1c1d.
But now i think this problem is wrong, because in this case it exceeds the
size of the array if we try to o/p as 1a1b1c1d. Hence we require a new array
for it.
--
You received this message because you are subscribed to
ya got it now. I misunderstood the question
--
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.
1. Square each element of the array and then sort it---O(nlogn)
2. for(i=0;i(size-3);i++)
{
j=i+1; k=size-1;
while(jk)
{
if(a[[i] + a[j] == a[k])
printf(\n%d %d %d,sqrt(a[i]),sqrt(a[j]),sqrt(a[k]));
else if(a[i] + a[j] a[k])
j++;
C
--
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 at
Plz give the answers ...
1. In a binary max heap containing n numbers, the smallest element can be
found in time ??
2. The number of total nodes in a complete balanced binary tree with n
levels is,
a)3^n + 1
b)2^(n+1) - 1
c) 2^n + 1
d) none of above
3. In a country where everyone wants
the order of printfs depend on the scheduling algorithms which OS is
following and can't be predicted
--
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
@aditi : the ans is 3. Why do u think there is no definite ans ?
--
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
@aditya : can u explain how u got c part as the answer for question 2
--
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
@programming love : 6.5 can be represented accurately in binary
--
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
@programming love : 0.1 can't be represented accurately in binary. If u try
to convert it into binary, it will not terminate. Try it !! But 6.5 can be
converted.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
@swetha: This problem can't be solved in O(n)
--
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
Can anybdy explain the following questions :
(5) Find the output
int arr[2][3]={{1,2,3},{4,5,6}};
int (*ptr)[3]=a[0];
printf((%d,%d),(*ptr)[1],(*ptr)[2]);
ptr+=1;
printf((%d,%d),(*ptr)[1],(*ptr)[2]);
Will this program compile properly or will end in segmentation
fault ??
(9) Given a inorder
bubble sort
--
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
17/80
On Sun, Aug 7, 2011 at 10:34 AM, Algo Lover algolear...@gmail.com wrote:
A bag contains 5 coins. Four of them are fair and one has heads on
both sides. You randomly pulled one coin from the bag and tossed it 5
times, heads turned up all five times. What is the probability that
you
@coder : Cud u plz explain the approach for question 9 ??
--
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
the answer is 1/2
--
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
Is there any time limit for the questions in amazon online test ?
I mean shud we write efficient code or shud we just make our pgm rum ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
4. a
6 b
--
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
the code given in question 5 should not terminate because of the condition
of the for loop
--
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
ya the answer for 1st one is b
--
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
@sukran: 40%of work i.e. 120 sec of work is sequential and can't be
distributed among multiple processors. Since we hv to complete the work in
150 sec, so we r left with 30 sec. Remaining 60% work=180sec.
180/30=6
So we require 5 additional processors
--
You received this message because you
@neha: Cud u explain how r u getting d option for ques 4 ??
--
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
A[3][4]= 1049
B[3][4]= 2196
--
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
@aditi: explain ur answer.. How u got it ?
--
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.
yeah Siddarath's point is correct that they do hv preprocessors to prevent
multiple includes. And they would be using #ifndef instead of #pragma as it
is not a documented standard
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
First traverse the string and hash each word into a hash table if it is not
present in the hash table.
Then again traverse the string and hash each word. If the word is not
present in the hash table, output it to the console.
--
You received this message because you are subscribed to the Google
If no extra memory is allowed, then I think we can't do better than O(n^2),
which is pretty straight forward.
--
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
error
because head is a pointer to the structure, hence head.x gives an error
--
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
Can anybody explain following questions from the above interview:
Question:
Output:
int main()
{
char *str = “junk”;
scanf (“%[A telephonic girl]”, str);
printf (“%s\n”, str);
return 0;
}
Question : Data Structure that can be useful for the calculation like ab
BCNF
--
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 at
What happens when a thread calls exec ?? What happens to the other threads
of the same process ??
--
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,
@Dipankar: But all the threads of a process share code and data section. So,
how is it possible that they are not affected ???
--
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
Thnks Azhar :)
got the point
--
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
@aditi:Thats a non uniform rope. The 1st half may burn faster than 2nd half.
btw Priyanka's solution is correct.
--
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
Find LCA in n ary tree ?
--
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,
@Aanchal : My mistake... Its complexity can't be O(n^2)
--
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
Given two lists write a function which returns a list which is the
intersection of the two lists.the original lists should remain same.
(Intersection - if first list is say,1,20 3,45 and second list is 3,24
,45,90,68 then intersection should be 3,45 )
--
You received this message because you are
Its compiler dependent. Acc. to the C standard an object's stored value can
be modified only once in an expression.
--
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
ya, I also can't think anything better than O(m*n)
--
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
For question 1:
Take 2 arrays prod_before[N] and prod_after[N] which hold product of
elements before and after i respectively
For i=1 to N-1
calculate prod_before[i]
For i=N-2 to 0
calculate prod_after[i]
prod_before[0]=prod_after[N-1]=1
For i=0 to N-1
prod[i]=prod_before[i] *
For question 2:
1. check with empty string.
2. check with a string which is in the file
3. check with a string which is not in the file
4.check with a string which has a different case as that in the file. eg. if
the file contains structure and does not contain Structure, check find and
replace
Anybody having any of question 3 ???
--
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
@Poised: Whats the answer of :
double round(double num)
{ return (int)(num+0.5)
}
will it work all the time?
I think the answer should be Yes.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
1.*What is the wrong in this program
*main()
{
char *p,*q;
p=(char *)malloc(25);
q=(char*) malloc(25);
strcpy(p,amazon );
strcpy(q,hyd);
strcat(p,q);
printf(%s,p);
}
2.*write prefix and post fix notation for (a+b)*c-(d+e)^(f-g)
3.**what is valid in cpp char *cp; const char *cpp; 1) cpp=cp; 2)
@amit: can u supply the code for ur approach ??
--
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
for question 3:
cpp=cp is the correct answer. Can anybody explain ?
--
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
thnks amit..
--
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
@payel : Is it sub-sequence or sub-array ?? A sub-sequence may not be
continuous but a sub-array must be continuous. eg : What wud be the answer
for- 100110 ??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
You are given a large string. You need to cut the string into chunks such
that each substring that you get is a palindrome. Remember that each 1
length string is always a palindrome. You need to find the minimum number of
cuts that you need to make such that each substring is a palindrome.
--
@Ravinder : Its not a DP problem.. If it was, where are the sub problems
reused or in other words, where is memoization ??
@Anchal : Its complexity is O(n^2). Look at the following segment in ur code
:
for(int i=index[n];isz;i++)
{
index[n+1]=i;
just use the following recurrence relation :
let arr[] be the array of integers and take an array a[]
a[i]=max(a[i-2], a]i-1], a[i-2]+arr[i]);
a[0]=arr[0];
a[1]=max(arr[0],arr[1]);
a[N-1] contains the final answer
@abhishek : the output for {3,5,7,10} should be 5+10=15 and not 13 as
pointed by
@raja : The range is 1-N^2 and not 1-N. Had it been 1-N , we could have
easily sorted the array in O(N) time using bit map.
--
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
yup its correct...
--
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
If x is the number which is to be checked,
if (x !(x (x-1)) == 0)
then power of 2
--
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
Let S be the exact amount for which minimum coins are to found. And denom[]
be the array which contains different denominations. Let N be the size of
the denom[] array.
Algo:
1. int memo[S]
2. initialize all its elements to infinite
3.for i=1 to S
for j=0 to N-1
if(denom[j] i
I have used dynamic programing to solve the problem. I have used memo[]
array to memoize the value of previous state.
You should take an example and try to work it out using the algo...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
It means a very large value, can be the max value that an integer can
hold
--
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
@aman: My mistake.
set* memo[0]=0*
The revised algo is :
Algo:
1. int memo[S]
2. initialize all its elements to infinite. *
3.memo[0]=0*
4.for i=1 to S
for j=0 to N-1
if(denom[j] imemo[i-denom[j]] +1 memo[i])
memo[i]=memo[i-denom[j]] +1
5. return memo[S]
--
@anika: Here is the iterative code:
void iter_mirror(Node *root)
{
if(root==NULL)
return;
Node *stack[100];
Node *temp,*temp1;
int top=-1;
stack[++top]=root;
while(top!=-1)
{
temp=stack[top];
temp1=temp-left;
temp-left=temp-right;
Here the required program :
void findkthSmallest(Node *root,int k)
{
Node *stack[100];
int top=-1,count=0;
Node *temp;
stack[++top]=root;
/*First we will find the minimum node*/
temp=root;
while(temp-left != NULL)
{
stack[++top]=temp-left;
In the question it is specified that the data structure should have a worst
case time complexity of O(N)
--
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
use the following recursive equation :
S{i]=max(S[i-2]+a[i],S[i-1])
S[0]=a[0]
S[1]=max(a[0],a[1])
S[size-1]is the required answer
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
1. Make an array S equal to the length of the given array where
S[0] = a[0] and S[1] = max(a[0],a[1])
2. for i:2 to n-1
S[i] = max(S[i-2]+a[i], S[i-1])
3. return S[n-1]
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
O(n^2) algo is trivial. Can anybody think of a better approach ???
--
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
Following is the working code :Time complexity : O(n^2) Space
complexity : O(1)
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
/*num is the number which is searched in the array arr[]. index is the index
in the array arr[] by which the searched number is to
@anand: How are you building minheap ?? Comparison of same array elements
is not allowed !
--
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,
First make an iterative DFS function which stores node pointers on the stack
instead of node values and break as soon as the node value of the node
pointer on the top of the stack reaches a specified value.
void iterative_dfs(Node *root,int n1);
Let n1 and n2 be the values whose LCA is to be
d) Hast table with bucket, made up of linked list, where linked list
have no ordering.
--
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
The O/P of ur example should be 2,2,1,1,1,-1,-1
or am I getting it wrong ??
--
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
@Akshata : Plz explain ur algo... Its not clear.
Like in the first iteration,
else
l = stk.top;
is getting executed. but stack is empty, so how r u assigning value to l
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
@Swetha :Number of possible sub strings of a string of length n is of
the order of n^2.
So, there can,t be a better solution than O(n^2)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
D) S1 and S2 both are true
S2 is true because
return a[i+2]-3; takes more time than return t2-3;
--
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,
@vivin : Suffix trees are memory intensive..
This problem can be solved just by running 2 nested loops in O(1)
space and O(n^2) time
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@vivin : Your algo seems to be wrong. Plz take an example and
explain. I may hv misunderstood u ..
--
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
int getFirstIndexInLex(char arr[],int size)
{
int minindex=0,i;
for(i=1;isize;i++)
{
if(arr[i] arr[minindex])
minindex=i;
else if(arr[i]==arr[minindex])
minindex=checkmin(arr,size,minindex,i);
}
return minindex;
}
int checkmin(char
There is a mistake in my code:
In the function
int checkmin(char arr[],int size,int i,int j)
after the while loop in the line
if(k==0)
It shud be :
if(k==size) instead of if(k==0)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
@coder: my mistake. There is a typo in my code.
the condition is :
while(arr[i]==arr[j] ksize)
--
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,
@coder : No, my solution gives the correct answer. Check it out again !!
--
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
@coder :Got my mistake. There is a slight change in the checkmin function.
Actually I was returning the modified value of i and j. Following is the
correct code :
#includeiostream
using namespace std;
int checkmin(char arr[],int size,int i,int j)
{
int k=0,*m=i,n=j*;
while(arr[i]==arr[j]
@rajeev:ur algo does not give the correct answer.
--
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
@bharath :I think array C is not the resultant array. Take an example and
explain
--
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
Incomplete Information
--
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,
1 - 100 of 191 matches
Mail list logo