FastPrepFlat JSON Value Differences
Problems/Flat JSON Value Differences

Flat JSON Value Differences

Chubb logoChubb● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names this algorithm exercise. We chose the function signature, the limits, the rules for fixed answers, and the examples.

Each input is a valid JSON object with unique alphanumeric keys and string values. Return all keys present in both objects whose values differ.

Return the keys in ascending lexicographic order. Keys appearing in only one object are ignored.

Function

differentCommonKeys(firstJson: String, secondJson: String) → String[]

Examples

Example 1

firstJson = "{\"name\":\"John\",\"age\":\"30\",\"status\":\"active\"}"secondJson = "{\"name\":\"John\",\"age\":\"31\",\"status\":\"inactive\",\"role\":\"admin\"}"return = ["age","status"]

Only common keys with unequal string values survive, then lexicographic sorting determines the result.

Example 2

firstJson = "{}"secondJson = "{}"return = []

Only common keys with unequal string values survive, then lexicographic sorting determines the result.

Example 3

firstJson = "{\"a\":\"1\"}"secondJson = "{\"a\":\"1\"}"return = []

Only common keys with unequal string values survive, then lexicographic sorting determines the result.

Constraints

  • Each JSON string has length at most 100000.
  • Objects are flat and contain only unique ASCII alphanumeric keys and ASCII alphanumeric string values.
  • Whitespace may appear outside quoted strings.

Source note: Author-written prompt excerpt retained for source fidelity.

More Chubb Online Assessment questions

  • Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
  • Index of the Maximum After Left RotationsOA · Seen Oct 2026
  • Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
  • Minimize the Maximum Array ElementOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Maximum Student-Teacher DistanceOA · Seen Sep 2026
  • Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
  • Minimum Last-Element RelocationsOA · Seen Sep 2026
  • Most Visited Sprint MarkerOA · Seen Sep 2026
  • How Many Sentences?OA · Seen Sep 2026

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
  • Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
  • Most Frequent CharacterMicrosoft · OAMicrosoft interview questions
  • Get Maximum Information GainAmazon · OA
  • Better CompressionGoldman Sachs · OAGoldman Sachs interview questions
  • Process LogsSnowflake · OASnowflake interview questions
All Chubb interview questionsSee Chubb hiring insights
Saved
class Solution {
    public String[] differentCommonKeys(String firstJson, String secondJson) {
        // Write your code here.
    }

}
Checking account…