摘要:一、题目 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2
阅读全文
摘要:一、题目 Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not p
阅读全文
摘要:一、题目 Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after d
阅读全文
摘要:转载:https://blog.csdn.net/ly_ysys629/article/details/73849543 参考:https://blog.csdn.net/stevenkwong/article/details/52540605 数据规整化:合并、清理、过滤 pandas和pytho
阅读全文
摘要:转载: http://www.cnblogs.com/jiayongji/p/7119065.html 结巴是一个功能强大的分词库。 安装jieba pip install jieba 简单用法 结巴分词分为三种模式:精确模式(默认)、全模式和搜索引擎模式,下面对这三种模式分别举例介绍: 精确模式
阅读全文
摘要:函数格式为:apply(func,*args,**kwargs) 用途:当一个函数的参数存在于一个元组或者一个字典中时,用来间接的调用这个函数,并肩元组或者字典中的参数按照顺序传递给参数 解析:args是一个包含按照函数所需参数传递的位置参数的一个元组,是不是很拗口,意思就是,假如A函数的函数位置为
阅读全文
摘要:加上下面这句代码,输出时打印不换行 np.set_printoptions(linewidth=400) 强制输出小数方法:suppress=True 强制类型转换 d2 = d1.astype(int)
阅读全文
摘要:一、题目 Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You m
阅读全文
摘要:一、题目 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set
阅读全文
摘要:一、题目 Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will always be valid. 给定一个链接的 list,移除从
阅读全文
摘要:numpy中的multiply、*、matul 的区别 1、对于矩阵(matrix)而言,multiply是对应元素相乘,而 * 、np.matmul() 函数 与 np.dot()函数 相当于矩阵乘法(矢量积),对应的列数和行数必须满足乘法规则;如果希望以数量积的方式进行,则必须使用 np.mul
阅读全文
摘要:一、题目 Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all uni
阅读全文
摘要:一、题目 Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of th
阅读全文
摘要:一、题目 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit
阅读全文
摘要:一、题目 Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives
阅读全文
摘要:一、题目 Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 把给定的整数转换成罗马数字 二、思路 这道题其实跟13题是两个相反的过程,
阅读全文
摘要:一、题目 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two
阅读全文
摘要:遇到这样的情况,只需要把程序中的对应的map处改成如下,前面加一个list就可以啦!
阅读全文
摘要:一、题目 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see b
阅读全文
摘要:一、题目 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed
阅读全文
摘要:一、题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 参考博客:
阅读全文
摘要:一、题目 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally
阅读全文
摘要:一、题目 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (siz
阅读全文
摘要:一、题目 Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->
阅读全文