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, 22805 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 501 Views, 22805 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, 22805 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
- Daily Interview Problem: Count Number of Unival Subtrees
- Daily Interview Problem: Room scheduling
- Algorithm Interview: Shifted String
- Staying on a Chess Board
- Compare Version Numbers
- Spreadsheet Column Title
- Daily Interview Problem: Largest BST in a Binary Tree
- Autorun.inf Virus Protection
- Daily Interview Problem: Find the k-th Largest Element in a List
- Find Missing Numbers in an Array
©2006~2024 SteakOverCooked - 0.00722 Seconds(s) - 2563.561 KB/s - 29 Online Memory: 492.91 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="noindex, 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 !