Questions d'entretiens - Systems software engineer

1 k

Questions d'entretien pour Systems Software Engineer partagées par les candidats

Principales questions d'entretien

Trier: Pertinence|Populaires|Date
On a demandé à un Systems Software Engineer...27 avril 2012

Given a page size and a number, align the number with the nearest page. (Note: This was a phone interview question. The interviewer and I used an online document to share ideas about this problem.

7 réponses

I think that at the faster solution you mean int getAlignedValue_Fast(int pageSize, int valueToAlign) { return valueToAlign & ~(pageSize-1); } Note: There is a difference between !(pageSize-1) and ~(pageSize-1) ~(0x11) is 0xee !(0x11) is 0 Moins

I just wanted to point out that the "faster solution" only works if the pageSize is assumed to be a power of 2. For example, suppose pageSize = 10 (or 01010 in binary), and valueToAlign = 24 (or 11000 in binary), then the fast method would give 16, but it should be 20. Anyways, thanks for posting the question and solution. Moins

@observer I see how the mask works out for the alignment, why it is works mathematically? Thanks Moins

Afficher plus de réponses

Implement memcpy.

4 réponses

you should care about how src and dest are overlapped, and copy from left or from right. Moins

void my_memcpy(void *dst, void *src, int size) { for(int i=0; i Moins

void memcpy (void *dest, void *src, size_t length) { int *currSrc = src; int *currDest = dest; chat *charSrc, *chardst; size_t nTimes = length / sizeof(int) for(int i=0; i Moins

Afficher plus de réponses
Hudson River Trading

How would you triage and go about fixing infrastructure problems? Giving an input file, get the number of lines matching a specific piece of text using bash scripting. Give the percentage of lines in the file that match that string.

3 réponses

1.) I said hard to tell because that is a very vague question. 2.) Use grep and awk and wc. 3.) Use the above plus "bc" to calculate percentage. Moins

for: 2.) Use grep and awk and wc. I believe grep + uniq + wc would be better and simpler, right? Moins

for: 2.) Use grep and awk and wc. 'grep -c' is enough


write a function to set a particular field of register to the desired value. ( For example, set bit 3 - 10 of a word to the given value)

3 réponses

Example: Value=0x1234 Desired Bits are 0,1, 7 & 15 Desired value=0x8083

Example: Value=0x1234 Desired Bits are 0,1, 7 & 15 Desired value=0x8083

Have you tried using this website? It says you can get career advice and interview prep info from Nvidia employees. Moins

Hewlett Packard Enterprise | HPE

You are hosting a party with 1000 bottles of wine and 10 servants, however, one of the bottles has been poisoned. How do you determine, using the servants, which bottle of wine is poisoned?

3 réponses

The below solution comes at the answer in 1 single try: Let the bottles have a 10 digit binary number (supports upto 1024 bottles). Servant 1 drinks from all bottles whose first binary digit is 1, and leaves those with digit 0 alone. (500 bottles) Servant 2 drinks from bottles with 2nd binary digit 1, and leaves alone digit 0, and so on. Depending on whether the servant dies or not, you have the binary digit that corresponds to him, and can root out the bottle with one iteration. However, this can kill upto 9 servants in single try depending on the number on the poisoned bottle. (Killing all 10 not possible as a number with all ones will number 1023, we dont have that many bottles) Moins

Let's divide the 1000 bottles among 10 servants. This way each servant has to check for only 10 bottles and they can start at the same time. If any servant dies, all other servants stop (given, only one poisonous bottle) ... So we know the exact bottle which is poisonous. Worst possible case, a servant needs to check all 10 bottles and the last bottle has poison. Moins

You can determine which bottle was poisoned by having a unique combination of servants try every bottle. For example servant 1 and 2 will try bottle 1. Servant 1, 2, and 3 will try bottle 2, and then continue on but with a unique combination of servants testing the bottles. Moins


Say the program you are running has stack overflow. You want to know when and where this happens, but you don't want to use debuggers, because they slow. How would you do this?

3 réponses

Manual Inspection or Ram dump should help

write a pattern to end of stack. uint32_t *StackPtr = (uint32_t *) 0x7FFFFFFF; //0x7FFFFFFFis end of stack *StackPtr = 0xDEADBEEF; A memory dump or a simple check in your code like will suffice if (*StackPtr != 0xDEADBEEF) { //Stack overflow } Moins

Align the stack memory at the end of a read only memory, this would cause an automatic err fatal Moins

Two Sigma

1. You have two strings. A test string and a glob Test string can have a & b, any number of times, any location. Glob can have a, b, ? and *, any number of times, any location. E.g. test= {a,b,a,a,a,a,b,b,b,b,b,b} glob = {a,?, *, b} Now, ? means ANY character, single occurrence. So it's either a or b, one time * means ANY OR NO character, any number of occurrences. E.g. the above glob and test actually match. Problem is: write an algorithm to match glob with test. You MAY NOT use regular expressions :D 2. The input is any string of any length of any characters. Write a program to generate ALL unique permutations of those characters. Unique. You may not store in an array or list, due to memory constraints. e.g. for input of abc your program should give 6 permutations but for aba your program should give 3. Hint: make the list alphabetical.

3 réponses

public class perm { public static void main(String[] args) { // TODO Auto-generated method stub String input = "abcdefg"; permutation(input, ""); } private static void permutation(String input, String sofar) { // TODO Auto-generated method stub if (input.equals("")) { System.out.printf("%s,", sofar); } for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (input.indexOf(c, i + 1) != -1) continue; permutation(input.substring(0, i) + input.substring(i + 1), sofar+c); } } } Moins

#include #include #include using namespace std; void str_permute(char *str, int start, int end) { if (start == end) { cout << str << endl; return; } bool char_set[256]; memset(char_set, 0, sizeof(char_set)); for (int i = start; i != end; ++i) { if(char_set[str[i]]) { continue; } char_set[str[i]] = true; swap(str[start], str[i]); str_permute(str, start+1, end); swap(str[start], str[i]); } } int main(int argc, char **argv) { str_permute(argv[1], 0, strlen(argv[1])); return 0; } Moins

As for the "regex" question, one way to go about solving this would be to create an NFA (non-deterministic finite automaton), turn it into a DFA (deterministic finite automaton), and manually parse the string. If the glob has length L and the query string has length M, constructing the DFA takes O(2^L) time and O(2^L) space while running the query through the DFA takes O(M) time. Moins


If we have a string : "abc ef 12 g", write a function that takes the pointer to the string reorganizes the string to be: "g 12 ef abc". Note that there are 3 spaces after abc, 2 spaces after ef, and 1 space after 12 in the original string, but the spaces are reversed. So in essence, write a function to reverse a string and then put the words between the spaces back in order. And the string length can be known or not.

3 réponses

I answered the question miserably....and didn't get to finish this question and obviously this may not be the best way to do it. assuming we know the string with strlength characters that are not \0 void myfun(char* string) { reverseString(string) //Reverse the characters between spaces here... } void reverseString(char* s) { for(int i = 0; i < strlenth/2; i++) { swap(s+i,s+(strlenth-1-i)); } } void swap(char* c1, char* c2) { char ctemp = *c1; *c1 = *c2; *c2 = ctemp; } Moins

#include #include using namespace std; void myReverse(string &str) { // First reverse the whole string : lkjol fdha hh eds reverse(str.begin(), str.end()); // Now iterate through and reverse sections separated by space string::iterator beg = str.begin(); string::iterator end = str.begin(); while (end != str.end()) { while ((*end != ' ') && (end != str.end())) end++; reverse(beg, end); while ((*end == ' ') && (end != str.end())) end++; beg = end; } } int main() { string mystring("sde hh ahdf lojkl"); cout << "\n str = " << mystring.c_str() << endl; myReverse(mystring); cout << "\n Afer str = " << mystring.c_str() << endl; return 0; } Moins

Through questions like this, interviewers are mostly trying to test your skillset (and its relevance to the role) as robustly as possible, so be prepared for multiple offshoots and followups. It could be a useful exercise to do mocks with friends or colleagues in Nvidia to get a real sense of what the interview is actually like. Alternatively Prepfully has a ton of Nvidia Systems Software Engineer experts who provide mock interviews for a pretty reasonable amount. Moins


write a function to check if an unsigned integer is a power of 2. if it is a power of 2, return the power. otherwise return 0.

3 réponses

Forgot these: typedef uint8 bool_t; #define true 1u #define false 0u

int findPowerOf2(unsigned int n){ int counter = 0; int numOnesFound = 0; int copy = n; while (copy > 0){ if (copy & 1 == 1){ if (!counter) counter++; numOnesFound++; } copy = copy >> 1; } if (numOnesFound > 1) return 0; else if (numOnesFound == 1) return counter; else return 0; } Moins

int checkpower(unsigned int n) { int power = 0; int counter = 0; int bitsSet = 0; while(n>0) { if((1u1) { return 0; } power = counter; } } return power; } Moins


How to swap 2 variables without using a third variable. And the team leader asked to write a code snippet for assigning 5 colors to the countries on the world map so that no adjacent country has same color.

2 réponses


x = x + y; y = x - y; x = x - y;

1 - 10 sur 1 000 questions d'entretien

Consultez les questions posées en entretiens pour des emplois similaires