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 |
main() { printf("%d", out); } int out=100;
How we print the table of 3 using for loop in c programing?
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }
main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }
void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }
how to return a multiple value from a function?
#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }
Write a C program to add two numbers before the main function is called.
3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.