File: root - text - article - 2019 - 12 - reverse-words-in-a-string.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 501 Views, 22815 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 501 Views, 22815 Search Bots | 102 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: "The cat in the hat"
Output: "ehT tac ni eht tah"
Note: In the string, each word is separated by single space and there will not be any extra space in the string.
Here's a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 501 Views, 22815 Search Bots | 102 Words Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: "The cat in the hat"
Output: "ehT tac ni eht tah"
Note: In the string, each word is separated by single space and there will not be any extra space in the string.
Here's a starting point:
class Solution:
def reverseWords(self, str):
# Fill this in.
print Solution().reverseWords("The cat in the hat")
# ehT tac ni eht tah
Related Articles
- Algorithm Interview Question: Symmetric k-ary Tree
- Daily Interview Problem: Find the k-th Largest Element in a List
- Generate All IP Addresses
- Staying on a Chess Board
- Algorithm Interview Question: Max and Min with Limited Comparisons
- A trick for getting good at coding interviews FASTER
- Daily Interview Problem: Trapping Rainwater
- Spreadsheet Column Title
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Floor and Ceiling of a Binary Search Tree
©2006~2024 SteakOverCooked - 0.0072 Seconds(s) - 2746.726 KB/s - 34 Online Memory: 493.02 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !