Quick Overview

This question evaluates fundamental programming skills such as string manipulation, algorithmic reasoning for numeric patterns, sequence generation, and data deduplication within the Coding & Algorithms domain for a Data Scientist role.

Solve Python Challenges: Reverse String, Palindrome, Fibonacci, Unique List

Company: OneMain Financial

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

##### Scenario Live coding round – four quick Python exercises ##### Question Implement a function that reverses a string in-place. Write code that returns True if a given integer is a palindrome, False otherwise. Generate the n-th Fibonacci number iteratively without recursion. Given an unsorted list of integers, return a new list containing only the unique values, preserving original order. ##### Hints Each task should run in O(n) time or better, and you may not import external libraries.

Quick Answer: This question evaluates fundamental programming skills such as string manipulation, algorithmic reasoning for numeric patterns, sequence generation, and data deduplication within the Coding & Algorithms domain for a Data Scientist role.

Given an unsorted list of integers nums, return a new list containing each distinct value exactly once, preserving the order of their first occurrence. Do not sort or otherwise reorder the input.

Constraints

  • 0 <= len(nums) <= 200000
  • -1000000000 <= nums[i] <= 1000000000
  • Preserve the order of first occurrences
  • Do not sort the input
  • Target time complexity: O(n)
  • Target space complexity: O(n)
  • Do not import external libraries

Hints

  1. Use a hash set to track which values have been seen.
  2. Append a number to the result only the first time it appears.
  3. Avoid sorting; membership checks in a set are O(1) on average.

Loading coding console...