AMD Coding Round Questions with Solutions
Last updated 2026-11-19
Coding questions at a processor company often mix language-lawyer output prediction with problems that touch the machine: simulate a cache, swap bytes, design an LRU cache. This page gives twelve practice problems in that style with complete solutions, complexity and typical mistakes.
They are practice problems for topics such rounds are commonly reported to cover, not real papers. Pair this page with AMD interview questions and C++ pointers interview questions.
How to approach them
For output prediction, trace the object lifetimes and the static or dynamic types before you answer. For design problems such as an LRU cache, state the required complexity first and choose the data structures from that.
Keep your code compilable and complete. Interviewers for these roles tend to run it.
Hiring status
This site holds no sourced hiring facts for AMD, so it quotes no dates or openings. Use the company's own careers site for what is open.
AMD Coding Round Questions with Solutions: questions with worked answers
1 Predict the output: a virtual function with different default arguments.
mediumDefault arguments are bound statically, from the type of the pointer, while the function body is chosen dynamically from the object. p has type Base*, so the default x = 1 from Base is used, but Der::f is called. Output: D1. Common mistake: expecting D2. Avoid overriding virtual functions with different defaults.
cpp#include <iostream> struct Base { virtual void f(int x = 1) { std::cout << "B" << x << "\n"; } virtual ~Base() {} }; struct Der : Base { void f(int x = 2) override { std::cout << "D" << x << "\n"; } }; int main() { Base *p = new Der; p->f(); // D1 delete p; }2 Predict the output: object slicing.
mediumspeak takes a Base by value, so passing a Der copies only the Base part; the dynamic type is lost and Base::name is called even though it is virtual. Output: Base. Passing by reference or pointer keeps polymorphism and would print Der. Common mistake: believing virtual always dispatches dynamically regardless of how the object is passed.
cpp#include <iostream> struct Base { virtual const char *name() const { return "Base"; } virtual ~Base() {} }; struct Der : Base { const char *name() const override { return "Der"; } }; void speak(Base b) { std::cout << b.name() << "\n"; } // sliced copy int main() { Der d; speak(d); // Base }3 Predict the output: a post-increment on a pointer to char.
easy*p++ reads the character p points to, then advances p. Adding 1 to the value of the character h (104) gives the character i, and p now points to the character e. The program prints i e. Postfix increment has higher precedence than dereference, but its value is the old pointer. Common mistake: reading *p++ as (*p)++, which would modify the string literal, which is undefined.
c#include <stdio.h> int main(void) { const char *p = "hello"; char c = *p++ + 1; printf("%c %c\n", c, *p); return 0; }4 Count the set bits across an array using a 256-entry lookup table.
mediumPrecompute the popcount of every byte value using t[i] = t[i / 2] + (i & 1), then sum t[b] for each byte of the data. Time O(n) lookups after O(256) setup. Compare with __builtin_popcount, which compiles to one instruction on CPUs that have it. Common mistake: indexing the table with a signed char, giving negative indices.
c#include <stdio.h> #include <stdint.h> int main(void) { uint8_t t[256] = {0}; for (int i = 1; i < 256; i++) t[i] = t[i / 2] + (i & 1); const uint8_t data[] = {0xFF, 0x0F, 0x01, 0x00}; int total = 0; for (size_t i = 0; i < sizeof data; i++) total += t[data[i]]; printf("%d\n", total); /* 13 */ return 0; }5 Rotate an N by N matrix 90 degrees clockwise in place.
mediumTranspose the matrix, then reverse every row. For [[1,2,3],[4,5,6],[7,8,9]] the result is [[7,4,1],[8,5,2],[9,6,3]]. Time O(N^2), space O(1). Common mistake: reversing columns instead of rows, which gives an anticlockwise rotation, or allocating a second matrix when in place was asked.
pythondef rotate(m): n = len(m) for i in range(n): for j in range(i + 1, n): m[i][j], m[j][i] = m[j][i], m[i][j] for row in m: row.reverse() return m print(rotate([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) # [[7, 4, 1], [8, 5, 2], [9, 6, 3]]6 Design an LRU cache with O(1) get and put.
mediumCombine a hash map with a doubly linked list. Python's OrderedDict does both: move_to_end marks a key as most recently used, and popitem(last=False) evicts the least recently used one. Both operations are O(1) average, space O(capacity). Common mistake: forgetting that get must also refresh recency, or using a plain list and paying O(n) per operation.
pythonfrom collections import OrderedDict class LRU: def __init__(self, cap): self.cap, self.d = cap, OrderedDict() def get(self, k): if k not in self.d: return -1 self.d.move_to_end(k) return self.d[k] def put(self, k, v): self.d[k] = v self.d.move_to_end(k) if len(self.d) > self.cap: self.d.popitem(last=False) c = LRU(2) c.put(1, 1); c.put(2, 2); c.get(1); c.put(3, 3) print(c.get(2), c.get(1), c.get(3)) # -1 1 37 Find the first non-repeating character in a string.
easyCount each character in one pass, then scan the string again and return the first with count 1. For "swiss" the answer is w. Time O(n), space O(k) for k distinct characters. Common mistake: scanning the counter dictionary instead of the string, which loses the original order in older Python versions and in other languages.
pythonfrom collections import Counter def first_unique(s): cnt = Counter(s) for ch in s: if cnt[ch] == 1: return ch return None print(first_unique("swiss"), first_unique("aabb")) # w None8 Simulate a direct-mapped cache and report hits and misses for an address trace.
hardSplit each address into block = addr // block_size, set = block % num_sets and tag = block // num_sets. A hit needs the stored tag to match. For a 4-line cache with 16-byte blocks and the trace 0, 4, 16, 64, 0, 32, 64 the result is 1 hit and 6 misses: address 4 shares block 0 with address 0, while 64 and 0 keep evicting each other in set 0. Time O(n), space O(sets). Common mistake: using the address, not the block number, to pick the set.
pythondef simulate(trace, sets=4, block=16): tags = [None] * sets hits = misses = 0 for a in trace: b = a // block s, t = b % sets, b // sets if tags[s] == t: hits += 1 else: misses += 1 tags[s] = t return hits, misses print(simulate([0, 4, 16, 64, 0, 32, 64])) # (1, 6)9 Generate the next lexicographic permutation of a list in place.
hardFind the rightmost index i with a[i] < a[i+1]; if none, reverse the whole list. Otherwise find the rightmost j with a[j] > a[i], swap, and reverse the suffix after i. For [1, 2, 3] the next is [1, 3, 2]; for [3, 2, 1] it wraps to [1, 2, 3]. Time O(n), space O(1). Common mistake: not reversing the suffix, which leaves it in descending order instead of the smallest order.
pythondef next_perm(a): i = len(a) - 2 while i >= 0 and a[i] >= a[i + 1]: i -= 1 if i >= 0: j = len(a) - 1 while a[j] <= a[i]: j -= 1 a[i], a[j] = a[j], a[i] a[i + 1:] = reversed(a[i + 1:]) return a print(next_perm([1, 2, 3]), next_perm([3, 2, 1]), next_perm([1, 3, 2])) # [1, 3, 2] [1, 2, 3] [2, 1, 3]10 Swap the byte order of a 32-bit value.
easyMove each byte to its mirrored position with shifts and masks: byte 0 to byte 3, byte 1 to byte 2, and so on. 0x11223344 becomes 0x44332211. Time O(1). GCC and Clang offer __builtin_bswap32, which maps to one instruction. Common mistake: using signed types, where right shifting a negative value is implementation-defined.
c#include <stdio.h> #include <stdint.h> uint32_t bswap(uint32_t x) { return (x >> 24) | ((x >> 8) & 0x0000FF00u) | ((x << 8) & 0x00FF0000u) | (x << 24); } int main(void) { printf("0x%08X\n", bswap(0x11223344u)); /* 0x44332211 */ return 0; }11 Predict the output: unsigned wrap-around and a loop that never ends.
mediumUnsigned arithmetic wraps modulo 2^32, so UINT_MAX + 1 is 0. The condition i >= 0 is always true for an unsigned i, so a countdown loop written with it never terminates; the loop below uses the "goes to" idiom and stops. Output: 0 3 2 1 0. Common mistake: using size_t as a loop counter in a downward loop with i >= 0.
c#include <stdio.h> #include <limits.h> int main(void) { unsigned u = UINT_MAX; printf("%u ", u + 1); for (unsigned i = 3; i-- > 0; ) printf("%u ", i + 1); printf("0\n"); return 0; }12 Sort an array of 0s, 1s and 2s in one pass without a library sort.
mediumDutch national flag: keep low and high pointers and a scan index mid. A 0 swaps with low and advances both; a 2 swaps with high and moves only high, since the swapped-in value is unexamined; a 1 just advances mid. Time O(n), space O(1). Common mistake: advancing mid after swapping with high, which skips checking the new value.
pythondef sort012(a): lo, mid, hi = 0, 0, len(a) - 1 while mid <= hi: if a[mid] == 0: a[lo], a[mid] = a[mid], a[lo]; lo += 1; mid += 1 elif a[mid] == 1: mid += 1 else: a[mid], a[hi] = a[hi], a[mid]; hi -= 1 return a print(sort012([2, 0, 1, 2, 1, 0])) # [0, 0, 1, 1, 2, 2]
Frequently asked questions
Are AMD coding rounds mostly C++?
Commonly reported for systems roles, but it depends on the team. Be ready for C++ output prediction, and for ordinary algorithm problems in a language of your choice if the test allows one.
What should I know for cache-related coding questions?
How an address splits into tag, set and offset, what direct-mapped and set-associative mean, and how access patterns change hit rates. Writing a small simulator is good practice.
Are these real AMD problems?
No. They are practice problems in the style of topics such rounds are commonly reported to cover. AMD does not publish its papers.
How do I prepare for C++ output questions?
Write the programs and run them, then explain every line. Focus on construction order, slicing, default arguments, const, references and undefined behaviour.
Related guides
More in Company Interview Questions
- AMD Interview Questions and Answers for India Software Roles
- American Express coding round questions with solutions
- American Express interview questions with answers (engineering)
- Analog Devices Coding Round Questions with Solutions
- Analog Devices Interview Questions and Answers for India Embedded and DSP Roles
- Apple Coding Round Questions with Solutions in Python and Java
- Apple Interview Questions and Answers for SDE Roles
- Arcesium Coding Round Questions With Solutions
- Arcesium Interview Questions and Answers
- Atlassian Coding Round Questions with Solutions in Python and Java
- Atlassian Interview Questions and Answers for SDE Roles
- Barclays coding round questions with solutions