is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
/* Include Header Files
- Azeemali Hashmani November 10, 2015*/
#include "stdio.h"
#include "stdlib.h"
/* Include Pre-processor directives
*/
#define N 100000
/* Function Proto-type
*/
void partition(long int *data, int first, int last);
void merge(long int *data, int first, int mid, int last);
/* Global Variable
*/
unsigned int counter = 0;
int main()
{
/* Declaring and initializing variables
*/
long int data[N] = {0};
int multiplying_factor = 10;
char c = '\0';
char d = 0;
long int sum = 0;
int indexcount = 0;
/* FILE READ OPERATION, USER CAN USE THEIR OWN FILE OPERATION
* IF NEEDED OR FOR SMALL ARRAY SIZE INITIALIZE THE VALUE
* OF ARRAY DURING DECLARATION
*/
/* Open file in directory
*/
FILE *fp = fopen("F:/IntegerArray.txt", "r");
/* Read till end of file
*/
while (c != EOF)
{
/* Reading file by character
*/
c = fgetc(fp);
if (c != '\n')
{
d = atoi(&c);
sum = (sum * multiplying_factor) + d;
}
else
{
/* Filling data in array
*/
data[indexcount] = sum;
indexcount = indexcount + 1;
sum = 0;
}
}
fclose(fp);
partition(data, 0, N - 1);
printf("\nCounter = %u \n", counter);
return 0;
}
void partition(long int *data, int left, int right)
{
int middle = (left + right) / 2;
if (left < right)
{
partition(data, left, middle);
partition(data, middle + 1, right);
merge(data, left, middle, right);
}
}
void merge(long int *data, int left, int middle, int right)
{
/* Declaring and initializing variables
*/
int Nleft = middle - left + 1;
int Nright = right - middle;
long int left_data[N] = {0};
long int right_data[N] = {0};
int index = 0;
int index_l = 0;
int index_r = 0;
/* Initialize left_data array
*/
for(index = 0; index < Nleft; index++)
{
left_data[index] = data[left + index];
}
/* Initialize right_data array
*/
for (index = 0; index < Nright; index++)
{
right_data[index] = data[middle + 1 + index];
}
index = left;
while (index_l < Nleft && index_r < Nright)
{
if (left_data[index_l] < right_data[index_r])
{
data[index] = left_data[index_l];
index_l++;
}
else
{
data[index] = right_data[index_r];
index_r++;
/* Updating counter
*/
counter = counter + (Nleft - index_l);
}
index++;
}
while(index_l < Nleft)
{
data[index] = left_data[index_l];
index++;
index_l++;
}
while(index_r < Nright)
{
data[index] = right_data[index_r];
index++;
index_r++;
}
}