Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
C Code Review for Benign Issues
00:00
5 left

C Code Review for Benign Issues

HardPython

Problem

What do you look for when reviewing C code for errors that might seem benign in a small project but are risky in production?

Implement a lightweight analyzer for a C source string. Return each applicable risk category at most once, ordered by the first occurrence of that category in the source. Ignore code inside // and /* ... */ comments. Treat an allocation as checked when its assigned variable is later compared with NULL or 0.

Input: one C source string. Output: a list of risk labels.

Constraints

  • 0 <= len(code) <= 5000
  • code contains a single C source string
  • Return each risk label at most once
  • Recognized labels are unsafe_input, unsafe_string_operation, format_string, and unchecked_allocation

Function Signature

def analyze_c_risks(code):
Interviewer

Your question is C Code Review for Benign Issues. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.