摘要: 字符串连接 方法1: 用字符串的join方法 方法2: 用字符串的替换占位符替换 字符串截取 我们可以通过索引来提取想要获取的字符,可以把python的字符串也做为字符串的列表就更好理解python的字串列表有2种取值顺序1是从左到右索引默认0开始的,最大范围是字符串长度少1s = 'ilovepy 阅读全文
posted @ 2017-12-12 22:28 西瓜刀刀刀 阅读(323) 评论(0) 推荐(0) 编辑
摘要: Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For 阅读全文
posted @ 2017-12-12 22:17 西瓜刀刀刀 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 在写C++程序中,总会遇到要从一个字符串中查找一小段子字符串的情况,对于在C中,我们经常用到strstr()或者strchr()这两种方法。而对于C++的string,我们往往会用到find()。 C++:#inlcude<string>C: #include<string.h>find():在一个 阅读全文
posted @ 2017-12-12 22:08 西瓜刀刀刀 阅读(11822) 评论(0) 推荐(1) 编辑
摘要: Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the or 阅读全文
posted @ 2017-12-12 21:25 西瓜刀刀刀 阅读(135) 评论(0) 推荐(0) 编辑
摘要: (1)代码: 阅读全文
posted @ 2017-12-11 22:38 西瓜刀刀刀 阅读(76) 评论(0) 推荐(0) 编辑
摘要: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文
posted @ 2017-12-11 22:22 西瓜刀刀刀 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 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,-1,2, 阅读全文
posted @ 2017-12-07 10:41 西瓜刀刀刀 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: You 阅读全文
posted @ 2017-12-07 10:21 西瓜刀刀刀 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2017-12-06 22:27 西瓜刀刀刀 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 给定一个m × n矩阵,如果一个元素为0,则将其整个行和列设置为0。 (1)思想1:用两个一维数组:flag_r 阅读全文
posted @ 2017-12-06 22:09 西瓜刀刀刀 阅读(116) 评论(0) 推荐(0) 编辑