File: root - text - article - 2019 - 11 - falling-dominoes.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 475 Views, 15047 Search Bots | 117 Words
| Browse | Archive
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 475 Views, 15047 Search Bots | 117 Words
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Hi, here's your problem today. This problem was recently asked by Twitter:
Given a string with the initial condition of dominoes, where:
. represents that the domino is standing still
L represents that the domino is falling to the left side
R represents that the domino is falling to the right side
Figure out the final position of the dominoes. If there are dominoes that get pushed on both ends, the force cancels out and that domino remains upright.
Example:
Input: ..R...L..R.
Output: ..RR.LL..RR
Here is your starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 475 Views, 15047 Search Bots | 117 Words Given a string with the initial condition of dominoes, where:
. represents that the domino is standing still
L represents that the domino is falling to the left side
R represents that the domino is falling to the right side
Figure out the final position of the dominoes. If there are dominoes that get pushed on both ends, the force cancels out and that domino remains upright.
Example:
Input: ..R...L..R.
Output: ..RR.LL..RR
Here is your starting point:
class Solution(object):
def pushDominoes(self, dominoes):
# Fill this in.
print Solution().pushDominoes('..R...L..R.')
# ..RR.LL..RR
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Related Articles
- Algorithm Interview: Make the Largest Number
- Plus One
- Consecutive Ones
- Autorun.inf Virus Protection
- YES!!
- Daily Interview Question: Find Cycles in a Graph
- Print a tree level-by-level, with line-breaks
- Non-decreasing Array with Single Modification
- Daily Interview Puzzle: Ways to Traverse a Grid
- Daily Interview Problem: Find the k-th Largest Element in a List
©2006~2024 SteakOverCooked - 0.01319 Seconds(s) - 4031.828 KB/s - 22 Online
Memory: 529.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="noindex, follow" />
![](/images/top.jpg)
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !