File: root - text - article - 2019 - 11 - falling-dominoes.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 736 Views, 18653 Search Bots | 117 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 736 Views, 18653 Search Bots | 117 Words
| Browse | Archive
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 | 736 Views, 18653 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
Related Articles
- Daily Interview Puzzle: Ways to Traverse a Grid
- Generate All IP Addresses
- Algorithm Interview: Shifted String
- Daily Interview Problem: Min Stack
- Design Tic-Tac-Toe
- Daily Interview Problem: Buddy Strings
- Plus One
- CVE-2015-8874 - cPanel EasyApache Vulnerabilities
- Autorun.inf Virus Protection
- Daily Interview Puzzle: Intersection of Linked Lists
©2006~2024 SteakOverCooked - 0.01424 Seconds(s) - 1350.196 KB/s - 21 Online Memory: 492.27 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 !