Adobe Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

// Assuming N rows and M columns
void change_pixels(char *grid, int N, int M, int x, int y, char new_pixel)
{
	// stride per row in bits
	int stride = M * 3;
	int bit_offset = y * stride + x * 3;
	int byte_offset = bit_offset / 8;
	int shift = bit_offset % 8;
	
	// read two bytes in case pixels are on byte boundary
	short int *tmp = (short *)(grid + byte_offset);
	short int tmp_pixels = *tmp;
	
	// store surrounding pixel bits (shift, one's complement and AND), and insert (OR) our new pixel bits
	tmp_pixels = tmp_pixels & ~(7 << shift);
	tmp_pixels = tmp_pixels | ((short int)new_pixel << shift);
}

- Anonymous September 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Is it correct ?
int stride = M * 3;
int bit_offset = y * stride + x * 3;

or it should be below?
int bit_offset = x*strinde + y*3

- vinit October 09, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It is y * stride, because the y coordinate determines the number of rows you are skipping.

- dexhop October 29, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

// Assuming N rows and M columns
void change_pixels(char *grid, int N, int M, int x, int y, char new_pixel)
{
	// stride per row in bits
	int stride = M * 3;
	int bit_offset = y * stride + x * 3;
	int byte_offset = bit_offset / 8;
	int shift = bit_offset % 8;
	
	// read two bytes in case pixels are on byte boundary
	short int *tmp = (short *)(grid + byte_offset);
	short int tmp_pixels = *tmp;
	
	// store surrounding pixel bits (shift, one's complement and AND), and insert (OR) our new pixel bits
	tmp_pixels = tmp_pixels & ~(7 << shift);
	tmp_pixels = tmp_pixels | ((short int)new_pixel << shift);
        *tmp = tmp_pixels;
}

- dexhop September 24, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>

int main(void) {
	char mat[3][2] = {
				'1','2', '3','4', '5', '6'
		};

	char *a = mat;
	int x=1;
	int y=1;
	
	int col = 2;
	char c = *((a + x*col) + y);
	printf(" original value : %c\n", c);
	c = c & 0x00;
	char given = '3';
	c = c | given;
	printf(" modified value : %c\n", c);
	return 0;
}

- nharryp November 04, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

typedef unsigned char b:3 pixel;
pixel *start; //pointer to beginning of grid
pixel newpix;
changepix(start,N,M,x,y,pix); // N = rows, M = columns

void changepix(pix* start,int N,int M,int x,int y,pixel pix) {
    start[Mx+y] = pix;
}

- iwanna September 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Why are you multiplying with "N". I think it should be " start[Mx+y] = pix; "

- Guest September 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is not correct. Each pixel is only 3 bits. The start array is a char array.

- ravio September 23, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

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.

Learn More

Resume Review

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.

Learn More

Mock Interviews

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.

Learn More