← All CodeSignal Technical Assessment Flashcard Decks

Array and String Manipulation Flashcards

7 cards from real CodeSignal Technical Assessment practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Array and String Manipulation flashcards as text
  1. What is the result of sorted([3,1,4,1,5,9], key=lambda x: -x)?

    Answer: [9, 5, 4, 3, 1, 1]

    Negating each value as the sort key sorts in descending order, yielding [9, 5, 4, 3, 1, 1].

  2. Which string method splits 'one,two,,three' by comma and returns empty strings for consecutive delimiters?

    Answer: 'one,two,,three'.split(',')

    str.split(',') treats each delimiter individually, preserving empty strings between consecutive commas → ['one','two','','three'].

  3. What is the worst-case time complexity of removing an element from the middle of a dynamic array (list)?

    Answer: O(n)

    Removing from the middle requires shifting all subsequent elements left by one, which is O(n) in the worst case.

  4. For the problem 'find the longest substring without repeating characters', which approach achieves O(n) time?

    Answer: Sliding window with a hash set tracking current window characters

    A sliding window expands the right pointer and shrinks the left pointer when a duplicate is found, processing each character at most twice → O(n).

  5. Given arrays A = [1, 3, 5] and B = [2, 4, 6], what is the median of the combined sorted array?

    Answer: 3.5

    Combined sorted array is [1,2,3,4,5,6]; median of 6 elements is average of 3rd and 4th: (3+4)/2 = 3.5.

  6. What does the following return: ['a','b','c','d'][::2]?

    Answer: ['a', 'c']

    Step-2 slicing picks every other element starting from index 0: indices 0 and 2 → ['a', 'c'].

  7. Which algorithm finds a peak element (element greater than its neighbors) in O(log n) time?

    Answer: Binary search modified to follow the ascending slope

    At any midpoint, if arr[mid] < arr[mid+1], a peak exists to the right; otherwise to the left — binary search locates it in O(log n).

Array and String Manipulation Flashcards — CodeSignal Technical Assessment Study Cards with Answers