FastPrepCorrect Apartment Bedroom Counts
Problems/Correct Apartment Bedroom Counts

Correct Apartment Bedroom Counts

Ramp logoRamp● MediumINTERNNEW GRADFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Ramp online assessment. The report gives the JSON format, the rules, an example, and the limits. Its sample reference code does not agree with one worked case, so our version follows the written rule and the example. Our version is about 99% the same as the reported question.

We want to query an API endpoint to receive data about currently available apartment listings from a rental website. Among the data fields is a column called num_bedrooms, which takes the value of 1 for a "1-bedroom" apartment and 0 for a "studio".

Note: This rental agency only works with studios and 1-bedroom apartments, so there will never be 2+ bedroom listings. Each listing includes information about a "studio" or a "1-bedroom" apartment, so there will never be a listing with both a "studio" and "1-bedroom" offerings in one posting.

The algorithm used occasionally mistags the num_bedrooms value. Specifically, sometimes a "studio" is tagged as having num_bedrooms = 1 or a "1-bedroom" is tagged as num_bedrooms = 0. Further investigation revealed it to be an issue with one of the data fields, description, and the way our algorithm parsed the field to extract a num_bedrooms value.

For example: "description": "Beautiful 1-bedroom apartment with nearby yoga studio." was detected as a yoga studio instead of 1-bedroom and incorrectly had num_bedrooms = 0.

Your task is to write a function that takes in the jsonData and corrects this problem. The GET request retrieves the data as a string which looks like this:

jsonData = [
  {
    "id": "3",
    "agent": "Ton Jett",
    "unit": "#12",
    "description": "Beautiful 1-bedroom apartment with nearby yoga studio.",
    "num_bedrooms": 1
  },
  ...
]

While correcting the problem, remember the following edge cases:

  • If the word "studio" or "1-bedroom" is preceded immediately by any of the words: "yoga", "dance" or "art", don't consider it for num_bedrooms value.
  • If the description does not contain the word "studio" or "1-bedroom", do not change the value for num_bedrooms.
  • The rules above should be applied regardless of punctuation or letter casing within the description field.

Your end goal is to return an array of integers representing num_bedrooms for each rental listing, example: [0, 1, 1, 1, 0, 0].

The source labels the following case Example.

For

jsonData = "[{\"id\":\"1\",\"agent\":\"Radulf Katlego\",\"unit\":\"#3\",\"description\":\"This luxurious studio apartment is in the heart of downtown.\",\"num_bedrooms\":1},{\"id\":\"2\",\"agent\":\"Kelemen Konrad\",\"unit\":\"#36\",\"description\":\"We have a 1-bedroom available on the third floor.\",\"num_bedrooms\":1},{\"id\":\"3\",\"agent\":\"Ton Jett\",\"unit\":\"#12\",\"description\":\"Beautiful 1-bedroom apartment with nearby yoga studio.\",\"num_bedrooms\":1},{\"id\":\"4\",\"agent\":\"Fishel Salman\",\"unit\":\"#13\",\"description\":\"Beautiful studio with a nearby art studio.\",\"num_bedrooms\":1}]"

the output should be solution(jsonData) = [0, 1, 1, 0].

The above jsonData represents the following JSON:

[
  {
    "id": "1",
    "agent": "Radulf Katlego",
    "unit": "#3",
    "description": "This luxurious studio apartment is in the heart of downtown.",
    "num_bedrooms": 1
  },
  {
    "id": "2",
    "agent": "Kelemen Konrad",
    "unit": "#36",
    "description": "We have a 1-bedroom available on the third floor.",
    "num_bedrooms": 1
  },
  {
    "id": "3",
    "agent": "Ton Jett",
    "unit": "#12",
    "description": "Beautiful 1-bedroom apartment with nearby yoga studio.",
    "num_bedrooms": 1
  },
  {
    "id": "4",
    "agent": "Fishel Salman",
    "unit": "#13",
    "description": "Beautiful studio with a nearby art studio.",
    "num_bedrooms": 1
  }
]

FastPrep practice clarification

  • The source's two explanation sentences using followed by are retained verbatim below. For judging, follow the explicit source rule: ignore a target occurrence when its immediately preceding word is yoga, dance, or art.
  • Match the complete words studio and 1-bedroom case-insensitively. Punctuation separates words, so ART...studio has art as the immediately preceding word.
  • Return corrected values in the same order as the listings in jsonData. If no non-ignored target occurs, retain that listing's original num_bedrooms.

Function

solution(jsonData: String) → int[]

Examples

Example 1

jsonData = "[{\"id\":\"1\",\"agent\":\"Radulf Katlego\",\"unit\":\"#3\",\"description\":\"This luxurious studio apartment is in the heart of downtown.\",\"num_bedrooms\":1},{\"id\":\"2\",\"agent\":\"Kelemen Konrad\",\"unit\":\"#36\",\"description\":\"We have a 1-bedroom available on the third floor.\",\"num_bedrooms\":1},{\"id\":\"3\",\"agent\":\"Ton Jett\",\"unit\":\"#12\",\"description\":\"Beautiful 1-bedroom apartment with nearby yoga studio.\",\"num_bedrooms\":1},{\"id\":\"4\",\"agent\":\"Fishel Salman\",\"unit\":\"#13\",\"description\":\"Beautiful studio with a nearby art studio.\",\"num_bedrooms\":1}]"return = [0, 1, 1, 0]

In the first listing, description = "This luxurious studio apartment is in the heart of downtown."

  • "studio" should have num_bedrooms = 0;

In the second listing, description = "We have a 1-bedroom available on the third floor."

  • "1-bedroom" should have num_bedrooms = 1;

In the third listing, description = "Beautiful 1-bedroom apartment with nearby yoga studio."

  • "1-bedroom" should have num_bedrooms = 1. Ignore "studio" since it is followed by "yoga".

In the fourth listing, description = "Beautiful studio with a nearby art studio."

  • "studio" should have num_bedrooms = 0. Ignore the second appearance of "studio" since it is followed by "art".

Example 2

jsonData = "[{\"id\":\"5\",\"agent\":\"Ari Lane\",\"unit\":\"#21\",\"description\":\"Bright YOGA, studio next to transit.\",\"num_bedrooms\":1},{\"id\":\"6\",\"agent\":\"Mina Park\",\"unit\":\"#22\",\"description\":\"A DANCE/1-BEDROOM rehearsal room is listed nearby.\",\"num_bedrooms\":0},{\"id\":\"7\",\"agent\":\"Noah Reed\",\"unit\":\"#23\",\"description\":\"Quiet apartment near the river.\",\"num_bedrooms\":1}]"return = [1, 0, 1]

FastPrep practice example: YOGA, studio and DANCE/1-BEDROOM are ignored because punctuation does not break the immediately preceding-word relationship. The last listing has no target word, so its original value remains 1.

Constraints

  • Input/Output
    • [execution time limit] 4 seconds (py3)
    • [memory limit] 1 GB
    • [input] string jsonData
      • String in JSON format. It's guaranteed that each listing contains the fields "id", "agent", "unit", "description" and "num_bedrooms".
      • Guaranteed constraints: 136 ≤ jsonData.length ≤ 15366.
    • [output] array.integer
      • Return an array that contains the correct values for num_bedrooms for all of the listings in jsonData.
  • FastPrep practice clarification: jsonData is valid standard JSON; description is a string, num_bedrooms is 0 or 1, and each source target or modifier is matched as a complete ASCII word.

Source note: The first four source images show the complete prompt, worked example, and original limits. The fifth shows the author's illustrative Python reference; where it differs, the explicit rule and worked example control.

More Ramp interview questions

  • Count Overlapping Square PairsOA · Seen Nov 2026
  • Count User Mentions in Chat MessagesOA · Seen Nov 2026
  • Accept or Decline QueriesOA · Seen Sep 2026
  • Recipe Management SystemOA · Seen Mar 2026
  • Task Manager with Timed AssignmentsOA · Seen Jan 2026
  • Bank Requests with Delayed CashbackOA · Seen Dec 2025
  • Convert Snake Case Variables to Camel CaseOA · Seen Apr 2025
  • Retryable URL MazePHONE SCREEN · Seen Oct 2026
  • Detect Recurring Transactions with Tunable TolerancesONSITE INTERVIEW · Seen Jul 2026
  • Find a User’s Airport from Flight HistoryPHONE SCREEN · Seen Sep 2025

Similar questions at other companies

  • Incident MonitorStripe · OAStripe interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Parse Command-Line TokensSamsara · ONSITE INTERVIEWSamsara interview questions
  • Reversible Run-Length EncodingZillow · PHONE SCREEN
  • Format CSV Rows as an ASCII TableAmazon · PHONE SCREEN
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Best TV Show in a GenreAdyen · OAAdyen interview questions
  • Cheating CodemakerJane Street · OAJane Street interview questions
  • Reflow and Fully Justify Text LinesIntuit · OAIntuit interview questions

Ramp interview experiences

  • Ramp interviews · November 2026
  • Ramp AI Coding Round, Experienced SWE Onsite: 3 Experiences
  • Ramp SWE New Grad OA and Phone Screen: 7 Experiences
  • Ramp Mobile and Android Interview Questions: 6 Experiences
All Ramp interview questionsSee Ramp hiring insights
Saved
class Solution {
    public int[] solution(String jsonData) {
      // Write your code here.
    }

}

Not a valid String

Checking account…