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 | 524 Views, 24169 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 524 Views, 24169 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 | 524 Views, 24169 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: String Compression
- Daily Interview Problem: Arithmetic Binary Tree
- Daily Interview Problem: Maximum Profit From Stocks
- Top K Frequent words
- Fix Brackets
- Sort a Partially Sorted List
- Algorithm Interview: Shifted String
- Daily Interview Problem: Jump to the End
- Non-decreasing Array with Single Modification
- Algorithm Interview: Longest Consecutive Sequence
©2006~2024 SteakOverCooked - 0.01193 Seconds(s) - 1655.704 KB/s - 15 Online Memory: 494.31 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 !