Data Structures & AlgorithmsModerateTCS NQT · Python basics
Problem: What does the following print?
Problem: What does the following print?
print(' '.join('the sky is blue'.split()[::-1]))- A. the sky is blue
- B. eht yks si eulb
- C. blue is sky the
- D. blue the is sky
Correct answer: C. blue is sky the
split() creates the word list, [::-1] reverses it, and join puts the words back with single spaces. Reversing each word's letters instead would give the trap eht yks si eulb.
More Coding Interview Problems questions
- Problem: Which statement about Hall's theorem for a bipartite graph with sides L and R is correct?
- Problem: Which claim about the complexity of deciding 2-SAT (satisfiability of clauses with at most two literals) is correct?
- Problem: Which of the following problems is NP-complete (decision version)?
- Problem: For Dijkstra on a graph with V vertices and E edges, which pairing of data structure and running time is correct?
- Problem: For a set of 40 items split into two halves of 20, the meet-in-the-middle approach solves subset-sum queries in roughly which time?
- Problem: Grundy numbers for the subtraction game where a move removes 1 or 2 stones: what are g(0) through g(5)? Run the code. python g =…