siva.sai.2020
- 12
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
16. Find out largest common SEQUENCE
e.g:
1)
str1: ABCDEF
str2: ABC
LArgest Common sequence: ABC
2) str1: ABCDEF
str2: ACEG
LArgest Common sequence: ACE
3)
str1: ABCDEF
str2: ZACYEFX
Largest common sequence : ACEF
NOTE: SEQUENCE need not be consecutive .
MAGMA Software Engineer / Developer Algorithm - 4
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
15. We have a special tree, in which every node contains random number of child nodes.
Note : each node can contains no. of child nodes between ZERO to INFINITY
sub questions:
1) node structure definition ?
2) which traversal you use ?. Traversal code ?
MAGMA Software Engineer / Developer Algorithm - 4
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
14) How you will achieve encapsulation in C language ?.
MAGMA Software Engineer / Developer C++ - 3
0of 0 votes
Answers<round 2>>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
13. Different types of TYPECASTS in C++ ?
MAGMA Software Engineer / Developer C++ - 5
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
12. Iterative Binary Search Algorithm with Single comparison .
MAGMA Software Engineer / Developer Algorithm - 1
0of 0 votes
Answer<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
11. Explain PREORDER, POST OREDER, INORDER. ?. To construct tree which 2 ORDERS needed ?
MAGMA Software Engineer / Developer Algorithm - 16
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
10. How many ZERO s in 100! ?
MAGMA Software Engineer / Developer Brain Teasers - 10
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
9. How to check given number is prime or not ?
MAGMA Software Engineer / Developer Brain Teasers - 2
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
8. Number N is given to you. You have to print all Permutations between 1 to N.
e.g
1) N = 2
o/p: 1 2
2 1
2) N =1
O/p : 1
MAGMA Software Engineer / Developer Algorithm - 1
0of 0 votes
Answer<round 2>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
7. Quick Sort avg and Worst case complexity . write code for Quick sort ?
MAGMA Software Engineer / Developer Algorithm - 3
0of 0 votes
Answers<round 1 >
6) what is fork()
sub questions
1) How many times "SIVA" will be printedi = 0 ; while (i < n ) { fork(); printf("\n SIVA"); i++; }2)How many times "SIVA" will be printed
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flagi = 0 ; while (i < n ) { printf("\n SIVA"); fork(); i++; }
MAGMA Software Engineer / Developer Algorithm - 1
0of 0 votes
Answer<round 1>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
5) Explain about Thread Pool ?
MAGMA Software Engineer / Developer Algorithm - 3
0of 0 votes
Answers<round 1>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
4) Difference between Flip-FLOP ? Where we use flip flop ?
MAGMA Software Engineer / Developer Computer Architecture & Low Level - 1
0of 0 votes
Answer<round 1>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
3) Unbalanced or Skewed binary tree root is given to you. You have balance tree by doing LEFT and RIGHT rotations.
MAGMA Software Engineer / Developer Algorithm - 1
0of 0 votes
Answer<round 2 >
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
2) Write your own "cp" command to copy files.
MAGMA Software Engineer / Developer Algorithm - 5
0of 0 votes
Answers<Round 1>
- siva.sai.2020 on February 16, 2011 Edit | Report Duplicate | Flag
1) Iterative Single Linked List Reverse
MAGMA Software Engineer / Developer Algorithm - 3
0of 0 votes
Answers5) Can we crash a process before entering Main() function ?
I said possible and I give following two examples
example 1:int *i = 0; int j = *i; // I think here memory access violation since pointer 'i' pointing 0th address. int main() { return 0; }Example 2:
int i = 1 / 0; // here Float point exception or divided by zero exception. int main() { return 0; }Today I executed , above two examples and I am getting compile time error "Line 2: error: initializer element is not constant
- siva.sai.2020 on February 13, 2011 Edit | Report Duplicate | Flag
" .
Can some one please tell me why I am getting compile time error ?
Gluster Software Engineer / Developer C - 6
0of 0 votes
Answers4) How to initialize Constant variables in class( or object).
example 1: throws error "uninitialized member 'myclass::i' with 'const' type 'const int'
"#include <iostream> using namespace std; class myclass{ public: const int i; myclass() { i = 10; // here throws error } }; int main() { myclass m; cout<<m.i<<endl; return 0; }example 2: below piece of code works fine .
#include <iostream> using namespace std; class myclass{ public: const int i; myclass() : i(10) { } }; int main() { myclass m; cout<<m.i<<endl; return 0; }Can some one please explain me , why second example works fine ? . why not first example ?
- siva.sai.2020 on February 13, 2011 Edit | Report Duplicate | Flag
Gluster Software Engineer / Developer C++ - 4
0of 0 votes
Answers3) Littele Endian vs Big Endian ?
- siva.sai.2020 on February 13, 2011 Edit | Report Duplicate | Flag
Sub questions:
1) which one decides endianess , Processor(CPU) or Operating System ?
2) There any standard ways to convert little endian data to big endian and vice versa .
My answer:
Linux is little endian and Solaris is big endian.
After that I said Processor(CPU) decides endianness of the machine. Intel processor supports little endian and SPARCV( Solaris) processor supports big endian.
He asked what about Solaris operating system with Intel processor ?. I said it is little endian.
Am I correct ?
Gluster Software Engineer / Developer Computer Architecture & Low Level - 0
0of 0 votes
Answers2. write down Linux "grep" command code.
- siva.sai.2020 on February 13, 2011 Edit | Report Duplicate | Flag
Input: file and a pattern
Eg.
$ Mygrep "siva*" names.txt
Output:
print entire line if it contains "Siva" word or prefix.
e.g:
"good bad siva is bad boy."
"sivabrtt gjfg"
After that asked me to write code to support regular expressions like "Siva*", "siva+venkat", "^siva".
Gluster Software Engineer / Developer Algorithm - 4
0of 0 votes
Answers1) Print tree in reverse Spiral Order .
Input:1 / \ 2 3 / \ / \ 4 5 6 7Output: 4->5->6->7->3->2->1
- siva.sai.2020 on February 13, 2011 Edit | Report Duplicate | Flag
Gluster Software Engineer / Developer Algorithm - 8
0of 0 votes
Answersint main() { int i=10; { int i=100; printf("%d", i); } }1.what is the output ?
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
2. what signifies "{" "}" in above code .
"{" "}" will it create new "Activation Record" ( or Frame) in Stack ?
Amazon Software Engineer / Developer C - 6
0of 0 votes
Answers<round 3>
11. difference between Inline and macro functions.
sub question :
1) what happens if you apply inline on recursive function.
2) is there any Recursive Macro function ?
e.g#define SUM(x, y) do{ SUM(x,y); }while(0);is there any error ?
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
Amazon Software Engineer / Developer C - 11
0of 0 votes
Answers<round 3>
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
10. differences between
char *str = "SIVA" and char str1[]="SIVA"
sub questions:
1) where string literal i.e "SIVA" will be stored ( heap , stack, data or code segments) in above both cases.
2) char *str = "SIVA";
str[0] = 'f' ;
any error ? compile time error or run time error ?
3) char *p = (char *) str;
p[0] = 'f' ;
any error ? compile time error or run time error ?
Amazon Software Engineer / Developer C - 37
0of 0 votes
Answers<round 3>
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
9. Array A[n] it contains numbers from 1 to n but 1 number repeated. Find out missing number.
----------------------
I have not answered this question and manager not happy with my performance. THIS THE END OF THE BATTLE.
Amazon Software Engineer / Developer Data Structures - 4
0of 0 votes
Answers<round3 >
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
8.He asked me many Hashing questions.
Sub questions
1. What is hashing ?
2. you can write your own hash methods or you can use existing Hash methods in STL C++.
which one you prefer ? why ?
3. Write a Generic hash function & hash table , which should support all data types INT, FLOAT, STRINGS, and OBJECTS .
Amazon Software Engineer / Developer Data Structures - 33
0of 0 votes
Answers<round3> ( Manager round )
7. Check given tree is symmetric or not ?
e.g
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag1) Symmetric 1 / \ 2 2 / \ 3 3 2) non-symmetric 1 / \ 2 3
Amazon Software Engineer / Developer Data Structures - 14
0of 0 votes
Answers<round 2>
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
6. Quadrant contains N points and all are + ve points ( I mean both (X,Y) are +ve values).
sub questions:
1. How you will store( or Data structure) N points to make look up( or search) easy.
2. Find out closest point (Pj) for a entered point (Pi).
Note: He asked me time efficient solution.
User can add extra M points later point of time. So your solution should be Scalable.
Amazon Software Engineer / Developer Data Structures - 3
0of 0 votes
Answers<round 1>
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
5. Reverse single linked list .
Amazon Software Engineer / Developer Algorithm - 5
0of 0 votes
Answers<Round 1>
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
4. Grid[n][n] contains letters from 'A' to 'Z' randomly. You have to print all possible words from grid.
You are allowed to move Left, Right, Up and Down ( no diagonal move).
Sub Questions:
1. Write down Dictionary_Lookup() function prototype. ( I no need to implement Dictionary_Lookup() but I have to write down possible return value and its arguments ).
This help us to find out traversed characters forming word or not.
2. Write down complete code to print all possible words in Grid.
Amazon Software Engineer / Developer Algorithm - 24
0of 0 votes
Answers<written test >
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
3.check whether given single linked list is palindrome or not.
e.g: 1->2->1 palindrome
1->2->3 not a palindrome
Note: Time efficient and without using any other data structures.
Amazon Software Engineer / Developer Algorithm - 3
0of 0 votes
Answers<written test >
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
2. Two sorted arrays A[X] and B[Y+X]. in B array contains Y sorted elements and B can accommodate A[] X elements.
W.A.P to Merge two arrays and store resultant in B[] array.
Note: Time efficient and space efficient solution
Amazon Software Engineer / Developer Algorithm - 21
0of 0 votes
AnswersI appeared for the Amazon( Bangalore) Interview on 05-Feb-2011. I cleared written test. After that I gave 3 rounds of interview.
- siva.sai.2020 on February 08, 2011 Edit | Report Duplicate | Flag
Note: They are going conduct interviews on 13-Feb-2011 also. There is a chance to repeat following questions.
< written Test >
1. Preorder string"NNLLNLL" ( or similar string ) has given to you. You have to construct binary tree.
Here 'N' means non -leaf node.
Here 'L' means leaf node.
Note: every node contains 0 or 2 childrens.
Amazon Software Engineer / Developer Algorithm - 4
0of 0 votes
Answerswrite down String class copy constructor ?
- siva.sai.2020 on December 28, 2010 Edit | Report Duplicate | Flag
Microsoft Software Engineer in Test - 9
0of 0 votes
Answersfind a bug in following code : class A { public: static int i; void print() { cout<< i << endl ; } }; int main() { A a; a.print(); }I run above code, and I am getting "ndefined reference to `A::i'" . Why I am getting this error ?
- siva.sai.2020 on December 28, 2010 Edit | Report Duplicate | Flag
Microsoft Software Engineer in Test - 22
0of 0 votes
AnswersHow can we generate all possibilities on braces ?
- siva.sai.2020 on December 01, 2010 Edit | Report Duplicate | Flag
N value has given to us and we have to generate all possibilities.
**Examples:**
1) if N == 1, then only one possibility () .
2) if N==2, then possibilities are (()), ()()
3) if N==3, then possibilities are ((())), (())(),()()(), ()(()) ...
Note: left and right braces should match. I mean )( is INVALID for the N==1
How can we solve this problem by using recurrence approach ?
Amazon Software Engineer / Developer - 20
0of 0 votes
AnswersQuestion on Tree Data Structure: How can we fill all inorder successor pointer of all tree nodes ?
Tree node contains 3 pointers *left, *right and *Successor .Struct node{ int data; struct node *left; struct node *right; struct node *successor; };A / \ B C / \ / \ D E F GINORDER Traversal: **DBEAFCG**
**Note:** A inorder successors are F,C and G.
**Function prototype:** void FillSuccessorNodes( struct node *root);
Tree's root node given to us and we need to fill successor pointer for all nodes.case 1) some of the Successor pointers may be **NULL** . This case you have to fill that pointer with immediate Inorder Successor.
Example: if A->Successor == NULL, then fill A->Successor = F
case 2) some of the Successor pointers may already points to correct successors. This case You no need to modify successor pointers.
Example: 1) A->successor = F is valid
2) A->successor = C is valid
3) A-successor = G is valid . All these three cases you no need to modify successor pointer since these already pointing to correct successor nodes.case 3) Some of the successor pointers are **not NULL** but these pointers pointing to INVALID successors i.e it could be inorder successor or some garbage value. This case you have to fill these nodes with immediate successor nodes.
Example:
1) A->successor = B is invalid since B is not successor node , so we have to correct it to A->successor = F.
2) A->successor = 0x23237463478 is invalid since it is pointing to garbage value. So we we have to correct it to A->successor = F.**1) Interviewer asked me time efficient solution in O(n) time complexity. Extra space allowed. 2) she gave some hint i.e we can use HASHing.**
- siva.sai.2020 on December 01, 2010 Edit | Report Duplicate | Flag**If you know the solution for this problem, please let me know .**
Amazon Software Engineer / Developer
Youtube uses adobe flash player,
1. adobe flash player crashed
2. adobe flash player incompatible with browser through which you are playing youtube video
3. there is some problem with video file
debugging :
attach debugger and see adobe flash player is loaded are not.
once you attach debugger, you get all exceptions of the problem,and anlayze them.
#include <malloc.h>
#define QUEUE_SIZE 100
struct tree
{
int data;
struct tree *left, *right;
};
struct queue
{
struct tree *nodes[QUEUE_SIZE];
int front,rear;
};
void printLevelOrder(struct tree *root)
{
struct queue *Q = (struct queue *) malloc(sizeof(struct queue));
struct tree *P;
queueInit(Q);
queueAdd(Q, root);
queueAdd(Q, NULL);
while(!queueEmpty(Q))
{
P = queueDel(Q);
if(P == NULL)
{
if(queueEmpty(Q))
return;
printf("\n");
queueAdd(Q, NULL);
}
else
{
printf("%d,",P->data);
if(P->left != NULL)
queueAdd(Q, P->left);
if(P->right != NULL)
queueAdd(Q, P->right);
}
}
}
/* Queue functions */
void queueInit(struct queue *Q)
{
Q->front = Q->rear = -1;
}
void queueAdd(struct queue *Q, struct tree *node)
{
if((Q->front+1)%QUEUE_SIZE == Q->rear)
{
printf("\n Queue is full");
}
else
{
Q->front = (Q->front + 1)% QUEUE_SIZE;
Q->nodes[Q->front] = node;
if(Q->rear == -1 )
{
Q->rear = 0;
}
}
}
struct tree * queueDel(struct queue *Q)
{
if( Q->rear == -1)
{
printf("\n queue is empty ");
return NULL;
}
else
{
struct tree *temp = Q->nodes[Q->rear];
Q->rear = (Q->rear + 1) % QUEUE_SIZE;
/* Queue is empty */
if(Q->rear > Q->front)
{
Q->front = Q->rear = -1;
}
return temp;
}
}
int queueEmpty(struct queue *Q)
{
return Q->rear == -1 ? 1 : 0 ;
}
Nice solution
- siva.sai.2020 on March 29, 2013 Edit | Flag View ReplyNice solution
- siva.sai.2020 on March 29, 2013 Edit | Flag View ReplyLet us say X = XOR sum of all elements from 0 to N
Y = XOR sum of given elements ( 0 to N , one number missed )
X xor Y vallue is the missed number.
@sachin, nice code
- siva.sai.2020 on February 22, 2013 Edit | Flag View Replynice code, you handled all the cases
- siva.sai.2020 on February 22, 2013 Edit | Flag View ReplyNice solution!
- siva.sai.2020 on February 22, 2013 Edit | Flag View Replyint numOfPaths(int A[4][4], int n)
{
int B[4][4];
// if starting point blocked then no path is there to reach right down
if( A[0][0] == 0)
{
return 0;
}
else
{
int i,j;
for(i=0; i<n; i++)
B[0][i] = 1 & A[n-1][i];
for(i=1; i<n; i++)
B[i][0] = 1 & A[i][n-1];
for(i=1; i<n; i++)
for(j=1; j<n; j++)
if( A[i][j] == 0)
B[i][j] = 0;
else
B[i][j] = B[i-1][j] + B[i][j-1];
return B[n-1][n-1];
}
}
int main()
{
int A[4][4] = {{1,1,1,1},
{1,0,1,1},
{1,1,1,1},
{1,1,1,1}};
int paths = numOfPaths(A, 4);
printf("\n numofpaths = %d\n", paths);
return 0;
}
We can solve this problem in O(n) time complexity.
Step1:
Array[] = {2,3,1,5} Permute[] ={5,2,1,3}
Step2:
2315 -->exchange 2 & 3
3215 -->exchange 3 & 5
5213
total 2 swap operations
Step3:
int i = 0, swapCount = 0, j;
while(i < n)
{
if( Array[i] == Permute[i] )
{
i++;
}
else
{
j = findElementIndex( Permute, A[i] );
Swap(A,i,j); // Swap i & j indexes elements
swapCount++;
}
}
correction
int main()
{
char input[] = {'a','b','c'};
char permute[3] = {};
permutations(input, permute, 3, 0);
return 0;
}
The Boyer-Moore Majority Vote Algorithm fails to find correct majority in the below input arrays
int numbers[SIZE] = {1,2,3,4,1,2,3,4,1,2,3,4};
int numbers[SIZE] = {1,2,3,4,1,2,3,4,1,2,3,4,1};
#include <iostream>
using namespace std;
class base{
};
class der : public base {
public:
der() : base()
{
//base();
cout<<"hello "<<endl;
}
};
int main()
{
der d;
return 0;
}
int main()
{
int a[] = { 1,4,6,2,3,0,5};
int lcs[100], p[100];
int i=0,j=0, maxIndex=0;
//initialize
int size = sizeof(a)/sizeof(a[0]);
for(i=0; i < size; ++i)
{
lcs[i]=1; p[i] = -1;
}
for(i=1; i< size; i++ )
{
for(j = i-1; j>=0; j-- )
{
if( (a[j] < a[i] ) && (lcs[i] < (lcs[j] + 1)))
{
lcs[i] = lcs[j]+1;
p[i] = j;
if( lcs[maxIndex] < lcs[i] )
maxIndex = i;
}
}
}
i = maxIndex;
do
{
cout<<a[i]<<",";
i = p[i];
}while(i!=-1);
return 0;
}
Time complexity O(n2)
- siva.sai.2020 on February 18, 2013 Edit | Flag View Replyint LCS[1024][1024];
int LongestCommonSubsequence( char pattern1[], int m, char pattern2[], int n)
{
if ( m >= 1024 || n >= 1024)
{
printf("\n too long pattern \n");
return -1; // return error -1
}
else
{
int i=0,j=0;
while(i<m)
{
LCS[i++][n] = 0;
}
while(j<n)
{
LCS[m][j++] = 0;
}
for( i = m-1; i>= 0 ; i-- )
{
for( j= n-1; j>=0 ;j--)
{
LCS[i][j] = LCS[i+1][j+1];
if(Pattern1[i] == pattern2[j] )
LCS[i][j]++;
if( LCS[i+1][j] > LCS[i][j] )
LCS[i][j] = LCS[i+1][j];
if(LCS[i][j+1] > LCS[i][j])
LCS[i][j] = LCS[i][j+1];
}
}
return LCS[0][0];
}
}
Time complexity O(mn)
- siva.sai.2020 on February 18, 2013 Edit | Flag View ReplyNOTE: I am learning efficient programming(i.e.. time & space optimized code,easily understandable code).If you find any error in my below code, could you please let me know errors/suggestions in the code.
struct list
{
int data;
struct list *next;
};
int isPalindromeRecursive(struct list *header, struct list **traverseNode)
{
if( (*traverseNode)->next == NULL )
{
*traverseNode = header->next;
return 1;
}
else if((*traverseNode)->next->next == NULL)
{
*traverseNode = header->next->next;
return header->data == header->next->data; // when list contains even no. of nodes
}
else
{
*traverseNode = (*traverseNode)->next->next;
if(!isPalindromeRecursive(header->next, traverseNode))
return 0;
if(header->data != (*traverseNode)->data)
{
return 0;
}
else
{
*traverseNode = (*traverseNode)->next;
return 1;
}
}
}
int isPalindrome(struct list *header)
{
if( header == NULL )
{
printf("\n Invalid list \n");
return -1;
}
else if(header->next == NULL)
{
return 1;
}
else if( header->next->next == NULL )
{
return header->data == header->next->data;
}
else
{
struct list *traverseNode = header;
if(isPalindromeRecursive(header, &traverseNode))
{
printf("\n list is Palindrome \n");
return 1;
}
else
{
printf("\n list is not Palindrome \n");
return 0;
}
}
}
NOTE: I am learning efficient programming(i.e.. time & space optimized code,easily understandable code).If you find any error in my below code, could you please let me know errors/suggestions in the code.
void mergingSortedArrays(int *A, int m, int *B, int n)
{
int i = m-1, j = n-1, k = m+n-1;
while( i >= 0 && j >= 0 )
{
if(B[j] >= A[i] )
{
B[k--] = B[j--] ;
}
else
{
B[k--] = A[i--] ;
}
}
while( i >= 0 )
{
B[k--] = A[i--];
}
}
Time complexity: O(n)
Space Complexity : O(1)
struct tree * constructTree(char *inputArray, int arraySize, int *index)
{
/* validating input */
if( input == NULL || *index >= arraySize )
{
return NULL;
}
else
{
struct tree newNode = (struct tree *) malloc ( sizeof(struct tree));
newNode->data = inputArray[*index];
newNode->left = newNode->right = NULL;
*index = *index+1;
if(inputArray[*index] == 'N')
{
newNode->left = constructTree(inputArray, arraySize, index);
newNode->right = constructTree(inputArray, arraySize, index);
}
return newNode;
}
}
I found code in stackoverflow site
static unsigned char our_memory[1024 * 1024]; //reserve 1 MB for malloc
static size_t next_index = 0;
void *malloc(size_t sz)
{
void *mem;
if(sizeof our_memory - next_index < sz)
return NULL;
mem = &our_memory[next_index];
next_index += sz;
return mem;
}
void free(void *mem)
{
//we cheat, and don't free anything.
}
I also thought same Solution in O(n) .
@Ashwin, if all elemtns are +ve , that case also time complexity is O(n).
int zeroSumSubArray(int A[], int n, int *start, int *end)
{
int cSum[n]; // cumulative sum array
cSum[0] = A[0];
for(int i=1; i<n; i++ )
{
cSum[i] = cSum[i-1] + A[i];
if( cSum[i] == 0)
{
*start = 0;
*end = i;
return 1; //found slice sub array
}
else
{
int index = hashFind(cSum[i]);
if( index == -1)
{
hashAdd(cSum[i]); // element does not find in hash table
}
else
{
*start = index + 1;
*end = i;
return 1;
}
}
}
return 1;
}
Time & space complexities O(n);
- siva.sai.2020 on May 27, 2012 Edit | Flag View Replycorrect solution
- siva.sai.2020 on May 27, 2012 Edit | Flag View Replyyour answer right. but second possibility i.e. thread solution is wrong
- siva.sai.2020 on May 14, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 14, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 14, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replycool
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View ReplyGreat answer
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replyerror : converting from 'B' to non-scalar type 'A' requested
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replyin the question, constructor code is
A(int ii , int jj) :i(ii),j(ii){}
j varaible also contains i value
nice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 13, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 12, 2012 Edit | Flag View Replynice
- siva.sai.2020 on May 12, 2012 Edit | Flag View ReplyWhen you deal with different objects
class one{
};
class two {
}
one = two ; is possible when you write your own overloaded = function
good answer
- siva.sai.2020 on May 12, 2012 Edit | Flag View ReplyThis is right answer
- siva.sai.2020 on May 12, 2012 Edit | Flag View Replyif machine is single processor, whole process will be blocked.
if machine is multi processor, whole process may not be blocked .
e.g. thread1 is executing on Processor 1 ( and thread blocked with I/O operation ), thread2 is executing on processor2 . thread1 & thread2 are executing independently so one thread may not block other thread .
test cases:
- siva.sai.2020 on April 12, 2013 Edit | Flag View Reply1. verify SMS receiver phone no.
2. whether sender opted for SMS plan or not (if he not opted for SMS plan, then his telecom operator does not allow him to send SMS )
3. huge SMS message
4. empty SMS message
5. sending message to multiple phone no.s (or group)