Given a list of numbers ( fixed list) Now given any other
list, how can you efficiently find out if there is any
element in the second list that is an element of the
first list (fixed list)
Answers were Sorted based on User's Feedback
Answer / ajay
@Karan Verma
as stated in the question, you can not sort the first list
(fixed list)
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / karan verma
Above method will be most efficient in terms of time
complexity that is O(n).
If we desire space complexity O(1)
--> sort the two lists O(nlogn)
--> find the missing no. O(n)
O(n+nlogn)=O(nlogn)
space complexity=O(1)
| Is This Answer Correct ? | 11 Yes | 7 No |
Answer / raghuram.a
Use a hash table for storing the no.s of 1st list.
now using hash function check whether there is a no. of 2nd
list in the 1st list.(no. of comparisons=no. of elements in
the list!!efficient?)
| Is This Answer Correct ? | 7 Yes | 5 No |
why is printf("%d %d %d",i++,--i,i--);
How can i find first 5 natural Numbers without using any loop in c language????????
main() { printf("%d, %d", sizeof('c'), sizeof(100)); } a. 2, 2 b. 2, 100 c. 4, 100 d. 4, 4
18 Answers HCL, IBM, Infosys, LG Soft, Satyam,
String reverse with time complexity of n/2 with out using temporary variable.
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.
5 Answers IITR, Microsoft, Nike,
source code for delete data in array for c
int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could anyone explain this to me.
2 Answers Bosch, eInfochips, HCL, IHCL,
void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }
Is the following code legal? typedef struct a { int x; aType *b; }aType
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }