GithubHelp home page GithubHelp logo

newcoder's Introduction

Newcoder 练习题

Programming language: Python 2.7.x

剑指offer66题 (更新中...)

思路:每次拿到小礼品的孩子的位置为 (上一个小孩子的位置+m-1)%(小孩总数),依次循环,直到列表中只有一个元素,输出即可

思路:采用递归的形式进行求解

思路:遍历字符串,若在该字符的前后都没有出现该字符,将该字符输出,遍历结束后若返回-1

思路:遍历数组,每次遍历时都新建一个没有当前字符的暂时数组,若当前字符在暂时数组中找不到与之相同的字符,将其添加至结果列表中,直到结果列表中的字符为2

思路:做法十分简单,a[n] = a[n-1] + a[n-2]

思路:调用python内置的 ** 进行幂运算

思路:与斐波那契数列做法相似

思路:a[n] = a[0] + ... + a[n-1]

思路:使用python内置的对于str的replace()方法

思路:将整数变为字符串,遍历字符串

思路:对于B中的每个元素,构建一个去掉A中对应该下标元素的数组temp,将temp中的所有元素进行乘积后赋值给B中对应位置的元素即可

思路:调用python内置的reverse()方法进行翻转

思路:遍历原始列表,依次向temp列表中添加元素,再调用sorted()方法对temp列表进行排序再进行中位数的计算(代码可以得到正确结果,但是再newcoder这里通过不了)

思路:旋转的次数就是数列头移到数列尾的次数,使用中间变量进行中转

思路:使用itertools迭代工具

其他练习题

思路:每次将手中的水瓶对3进行取余,将取余后的空水瓶加上换来的水瓶再进行兑换,直到手中的水瓶数量小于2,等于2时+1
思路:空水平数量/2,向下取整

思路:python支持大整数

思路:排序后将首位四个数进行三个为组进行乘积操作,输出数值最大的数(该方法可以输出正确结果,但是nowcoder这里通不过)

思路:新建一个列表,每次从原始列表中向新建列表中添加元素时先检测是否有相同的元素,有则不添加,没有则反之,添加完后调用sort()进行排序

newcoder's People

Contributors

jx-wang avatar

Stargazers

 avatar

Watchers

James Cloos avatar

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.