Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

81%
+7 −0
Challenges Backspace an array

Challenge Given an array consisting of positive integers and 0s, return it with 0s acting like backspaces. Leading backspaces do nothing, and more backspaces than elements also does nothing. Cre...

6 answers  ·  posted 3y ago by rak1507‭  ·  last activity 3y ago by Shaggy‭

Question code-golf
#4: Post edited by user avatar rak1507‭ · 2021-05-30T18:30:44Z (over 3 years ago)
  • ## Challenge
  • Given an array, return it with 0s acting like backspaces.
  • Leading backspaces do nothing, and more backspaces than elements also does nothing.
  • Credit: A comment on this [video](https://www.youtube.com/watch?v=erv_1LxEByk)
  • ## Test Cases
  • ```
  • [0,0,0,0,0,5,7] -> [5,7]
  • [1,2,0,3] -> [1,3]
  • [1,5,5,0,2,0,0,8] -> [1,8]
  • [1,2,3,4,0,0,9] -> [1,2,9]
  • [1,2,0,0,0,0,0] -> []
  • ```
  • ## Challenge
  • Given an array consisting of positive integers and 0s, return it with 0s acting like backspaces.
  • Leading backspaces do nothing, and more backspaces than elements also does nothing.
  • Credit: A comment on this [video](https://www.youtube.com/watch?v=erv_1LxEByk)
  • ## Test Cases
  • ```
  • [0,0,0,0,0,5,7] -> [5,7]
  • [1,2,0,3] -> [1,3]
  • [1,5,5,0,2,0,0,8] -> [1,8]
  • [1,2,3,4,0,0,9] -> [1,2,9]
  • [1,2,0,0,0,0,0] -> []
  • ```
#3: Post edited by user avatar rak1507‭ · 2021-05-30T18:30:15Z (over 3 years ago)
  • ## Challenge
  • Given an array, return it with 0s acting like backspaces.
  • Leading backspaces do nothing, and more backspaces than elements also does nothing.
  • Credit: A comment on this video <https://www.youtube.com/watch?v=erv_1LxEByk>
  • ## Test Cases
  • ```
  • [0,0,0,0,0,5,7] -> [5,7]
  • [1,2,0,3] -> [1,3]
  • [1,5,5,0,2,0,0,8] -> [1,8]
  • [1,2,3,4,0,0,9] -> [1,2,9]
  • [1,2,0,0,0,0,0] -> []
  • ```
  • ## Challenge
  • Given an array, return it with 0s acting like backspaces.
  • Leading backspaces do nothing, and more backspaces than elements also does nothing.
  • Credit: A comment on this [video](https://www.youtube.com/watch?v=erv_1LxEByk)
  • ## Test Cases
  • ```
  • [0,0,0,0,0,5,7] -> [5,7]
  • [1,2,0,3] -> [1,3]
  • [1,5,5,0,2,0,0,8] -> [1,8]
  • [1,2,3,4,0,0,9] -> [1,2,9]
  • [1,2,0,0,0,0,0] -> []
  • ```
#2: Post edited by user avatar rak1507‭ · 2021-05-30T18:29:37Z (over 3 years ago)
  • ## Challenge
  • Given an array, return it with 0s acting like backspaces.
  • Leading backspaces do nothing, and more backspaces than elements also does nothing.
  • Credit: A comment on this video https://www.youtube.com/watch?v=erv_1LxEByk
  • ## Test Cases
  • ```
  • [0,0,0,0,0,5,7] -> [5,7]
  • [1,2,0,3] -> [1,3]
  • [1,5,5,0,2,0,0,8] -> [1,8]
  • [1,2,3,4,0,0,9] -> [1,2,9]
  • [1,2,0,0,0,0,0] -> []
  • ```
  • ## Challenge
  • Given an array, return it with 0s acting like backspaces.
  • Leading backspaces do nothing, and more backspaces than elements also does nothing.
  • Credit: A comment on this video <https://www.youtube.com/watch?v=erv_1LxEByk>
  • ## Test Cases
  • ```
  • [0,0,0,0,0,5,7] -> [5,7]
  • [1,2,0,3] -> [1,3]
  • [1,5,5,0,2,0,0,8] -> [1,8]
  • [1,2,3,4,0,0,9] -> [1,2,9]
  • [1,2,0,0,0,0,0] -> []
  • ```
#1: Initial revision by user avatar rak1507‭ · 2021-05-30T18:29:19Z (over 3 years ago)
Backspace an array
## Challenge

Given an array, return it with 0s acting like backspaces.

Leading backspaces do nothing, and more backspaces than elements also does nothing.

Credit: A comment on this video https://www.youtube.com/watch?v=erv_1LxEByk

## Test Cases
```
[0,0,0,0,0,5,7] -> [5,7]
[1,2,0,3] -> [1,3]
[1,5,5,0,2,0,0,8] -> [1,8]
[1,2,3,4,0,0,9] -> [1,2,9]
[1,2,0,0,0,0,0] -> []
```