My Failed Interview Program Series #1

Hi Folks

In my previous post, I told that I was trying to become better at what I do thinking that I was actually good at what I do. What a SHAME!!!. Recently, I got to know that I am not even good at what I have been doing all these years. I learned that I am not good at time management, listening, practical concepts. These were all the feedbacks I received while sitting for a normal company that would not even test my competitive programming skills, which actually requires time management and problem solving and understanding. Only if I was not faced with an actual person, who was looking at me!!! Wish I were with an AI that conducted the test.

Well!!! could have, should have, would have are all the reasons of a loser.

Although I solved the program after the interviewer left within 5 minutes.

Below is one simple program which I failed to solve at the test.

/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
#include <string.h>

int check_if_anagram(char *s1, char *s2) {
    int m, n, k;
    m = strlen(s1);
    n = strlen(s2);
    
    k = 0;
    if (m == n) {
        for(int i = 0; i < n; i++)
            for(int j = i; j < n; j++) {
                if (s2[j] == s1[i]){
                    k++;
                    //printf("## %c %c k=%d\n", s1[j], s2[i], k);
                }
            }
    }
    if (k >= n)
        return 1;//true
    return 0;//false
}



int main()
{

    printf("Anagram\n");
    printf("%d\n", check_if_anagram("iamsmart", "stariamm"));
    printf("%d\n", check_if_anagram("iamsmart", "amismate"));
    
    //printf("%d\n", check_if_anagram("iii", "ijj", 3, 3));
    printf("%d\n", check_if_anagram("iii", "ijj"));
    printf("%d\n", check_if_anagram("iii", "iii"));
    return 0;
}

Ok, since this was my first company, I now have to do a course on interview preparation while relearning my c concepts