Posts

Showing posts with the label Interview Questions

Barracuda networks (A Bangalore's Startup) written Round Programming Questions

1) C program to copy one file to another. #include<bits/stdc++.h> using namespace std; int main() {     char ch,src[20],tgt[20];     FILE *s,*t;     gets(src);     s=fopen(src,"r");     if(s==NULL)     {         printf("press any key to exit\n");         exit(EXIT_FAILURE);     }     gets(tgt);     t=fopen(tgt,"w");     if(t==NULL)     {         printf("press any key to exit\n");         exit(EXIT_FAILURE);     }     while(( ch=fgetc(s))!=EOF)         fputc(ch,t);     return 0; } - ---------------------------------------------------------------------------------------------------------------------- 2 ) use function pointer to add , sub and multiply #include<bits/stdc++.h> using namespace std; ...

DMX technologies (A Bangalore's Startup) written Round Programming Questions

1) Spiral Matrix Printing     For example : if given n=2 , then output is   3 2                                                                        0  1                        if given n=3 , then output is   4  3  2                                                                       5  0  1                                                                   ...

LeadSquared Interview Questions

On 12th july , I got a chance to sit for the written round of Leadsquared drive. In 1 hour we have to do 3 java questions. 1st question->Excel sheet problem                       ex. 1 -> A , 2->B , 26->Z ,27->AA   import java.util.*; public class excel { public static void main(String args[]) {   Scanner s=new Scanner(System.in);        int r,n=s.nextInt();   String k=" ";        while(n>0)   { r=n%26;           if(r==0)  { String ch="Z";             k=k+ch; n=n/26 -1;  }           else  {  int ch=r-1+(int)'A';  char p=(char)ch;  String h= Character.toString(p);               k=k.concat(h);          n=n/26; ...

Directi Online Interview Question :- Two non-overLapping subarrays of size k which gives maximum sum

Directi Online Interview Question. Two non-overLapping subarrays of size k which gives maximum sum. This is a 1-D Dp approach ,in O(n) time-complexity. #include<bits/stdc++.h> using namespace std; int pre[1000],a[10000],dp[1000]; int main() {     int n,k;     cin>>n>>k;     for(int i=1;i<=n;i++) cin>>a[i];         pre[0]=0;         pre[1]=a[1];         dp[k]=pre[k];    ///upto length k     for(int i=2;i<=n;i++) pre[i]=pre[i-1]+a[i];     for(int i=k+1;i<=n;i++) dp[i]=max(dp[i-1],pre[i]-pre[i-k]);     int ans=0;     for (int i=k;i<=n;i++){     ans = max(ans,dp[i-k]+pre[i]-pre[i-k]);}     cout<<ans<<endl;     return 0; }