Coder Social home page Coder Social logo

platzimaster / challenge-python-09 Goto Github PK

View Code? Open in Web Editor NEW
1.0 5.0 18.0 4.83 MB

Duplica la cantidad de 0s en un arreglo de tamaño fijo

License: GNU General Public License v3.0

Python 100.00%
python time-60 algorithms-and-data-structures level-medium

challenge-python-09's Introduction

Duplicando 0s

Dada una lista de enteros arr, duplica cada 0 que encuentres moviendo todos los elementos a la derecha un lugar.

Observa que los elementos que terminen en una posición fuera del tamaño original del arreglo no deben ser escritos.

Resuelve este reto in-place, es decir, sin utilizar memoria adicional y modificando el arreglo recibido.

Ejemplo 1:

  • Entrada: [1,0,2,3,0,4,5,0]
  • Salida: None
  • Why?: Después de llamar tu función, el arreglo de entrada es modificado para formar [1,0,0,2,3,0,0,4].

Ejemplo 2:

  • Entrada: [1, 2, 3]
  • Salida: None
  • Why?: Después de llamar tu función, el arreglo de entrada es modificado para formar [1,2,3].

Notas: Existe una solución O(n) en tiempo.

Como subir mi solución?

  • Agrega un directorio con tu username de GitHub al directorio solutions, por ejemplo: solutions/pablotrinidad.
  • El directorio que agregues debe contener dos archivos; __init__.py (vacío) y solution.py.
  • El archivo solution.py debe contener lo siguiente:
from typing import List


class Solution:

    def duplicate_zeros(self, arr: List[int]):
        # AQUÍ VA TU SOLUCIÓN
  • Cuando tu solución esté lista, abre un PR en este repositorio.
  • El repositorio correrá pruebas de legibilidad (readability).
  • El repositorio probará que tu solución sea correcta.
  • Cuando las dos pruebas (grading y linting) pasen, alguien del team revisará y hará merge de tu PR.
  • Enjoy 💕.

Debugging

  • Puedes revisar que tu solución sea correcta en tu compu corriendo el comando python3 grader/main.py.
  • Puedes verificar la legibilidad corriendo pylint solutions/ (tal vez necesites pip install pylint antes).

challenge-python-09's People

Contributors

0xp4blo avatar alandavd avatar digitros avatar eocode avatar eriksape avatar hyfi06 avatar juanan150 avatar korkux1 avatar mariobarbosa777 avatar ricardoares1989 avatar sd8956 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

challenge-python-09's Issues

Define problem

Add:

  • Grader
  • Problem description
  • Submission instructions

[Bug] Grader is reusing output as input when printing failed test cases

Edit (by @pablotrinidad): Failed test cases will have the same values in input and ouput data since this specific problem modifies input in place. Grader must create a shallow copy of the input array before sending it to the valuation function.

Original:
When a test case fails, in the terminal it prints the input, output and expected. But input and output is equal, because the duplicate_zeros affects the original list.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.