摘要:一、题目 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can y
阅读全文
摘要:一、题目 Implement int sqrt(int x). Compute and return the square root of x. x is guaranteed to be a non-negative integer. 返回一个非负整数的平方根 二、题目解析 这个可以用二分查找来做
阅读全文
摘要:一、题目 Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 二进制加法 二、解题思路 第一种:先将二进制转换成十进制,做十进制加法,然
阅读全文
摘要:一、题目 Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any l
阅读全文
摘要:在python中循环的初始值永远从0开始,不管前面如何赋值,如下代码: 虽然起初我们给 i 赋值 1,但是开始下面循环的时候,i 初值依然为0。
阅读全文
摘要:一、题目 Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last
阅读全文
摘要:参考:http://www.runoob.com/python/att-string-split.html Python split()通过指定分隔符对字符串进行切片,如果参数num 有指定值,则仅分隔 num 个子字符串 语法: 其中str -- 分隔符,默认所有的空字符串,包括空格、换行(\n)
阅读全文
摘要:python中字典的使用非常普遍,字典也有很多方法,今天遇到了字典的get方法,用法如下: Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值。 语法: key -- 字典中要查找的键。 default -- 如果指定键的值不存在时,返回该默认值值
阅读全文
摘要:一、题目 Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,
阅读全文
摘要:python中有一中十分好用的功能:列表表达式或者列表推导式 目前先用到这么多,以后遇到再加
阅读全文
摘要:一、题目 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted
阅读全文
摘要:一、题目 The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "
阅读全文
摘要:一、题目 Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Example 2
阅读全文
摘要:集合的包含关系常见的有: 用法比较简单: L1.Intersect / Except / Union ( L2 ) 在实际应用过程中,遇到这样一个问题,代码附下: 如上代码所示,我的目的是想找到mList(类型为List<List<string>>,其中每个元素都是 List<string> 类型
阅读全文
摘要:一、题目 Given an array and a value, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array,
阅读全文
摘要:一、题目 Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra spa
阅读全文
摘要:一、题目 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.(合并两
阅读全文
摘要:一、题目 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in
阅读全文
摘要:参考博客:http://blog.csdn.net/nxhyd/article/details/71566780 一、题目 Write a function to find the longest common prefix string amongst an array of strings. 找
阅读全文
摘要:一、题目 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 二、思路解析 罗马数规则如下: 将数字和字符串对应,当然需要用到字典,循环
阅读全文
摘要:一、题目 Determine whether an integer is a palindrome. Do this without extra space. 二、解题思路 首先我想到的是把给定的数变成字符串,通过字符串反转判断是否相等来判断原数是不是回文数。首先要判断给定的数是不是负数,负数肯定不
阅读全文
摘要:一、TensorFlow安装 win 7 下安装 TensorFlow并不困难,cmd下 pip install TensorFlow即可 二、对于TensorFlow初学者,MNIST数据集试验就像是初学编程的“Hello,world”,第一次尝试并不困难,网上教程挺多。 参考博客: http:/
阅读全文
摘要:一、题目 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example 3: 二、解题思路 首先我想到的是字符串的反转问题,利用栈进行,先把给定的整数转换成字符串,然后把元素压入栈
阅读全文
摘要:一、题目 Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the
阅读全文
摘要:一、写在前面的 数组寻址容易,插入和删除困难;而链表寻址困难,但插入和删除容易;结合以上两点,衍生出哈希表结构。 比如在一个动态查找问题中,可以利用AVL树解决,但AVL树更擅长处理数字之间的比较,而变量名之间的比较是字符串之间的比较,字符串之间的比较需要一个一个地比较,比数字之间的比较复杂的多,如
阅读全文
摘要:一、题目描述 题目原文: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes cont
阅读全文
摘要:Python Basics with Numpy (optional assignment) Welcome to your first assignment. This exercise gives you a brief introduction to Python. Even if you'v
阅读全文