2dbi
Home/Qualcomm/Implement memcpy / Reverse a String In-Place
QQualcomm·DSASDE-1Onsite – Coding 1

Implement memcpy / Reverse a String In-Place

Problem

Implement memcpy handling overlapping regions correctly (i.e., memmove semantics), and reverse a C string in place.

Example

memmove with overlap; reverse("hello") -> "olleh"

Constraints

  • Handle overlap and null terminator

Approach

Copy direction depends on src/dst overlap. Discuss why naive memcpy corrupts overlapping ranges.

added 6 days ago
LeadersAccount