上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 37 下一页
摘要: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Not 阅读全文
posted @ 2017-09-22 21:42 immjc 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 给定一个字符串,要求把字符串前面的若干字符移动到字符串尾部。 解法一:蛮力法 首先想考虑将一个字符移到尾部的方法。代码如下: 如果要移动m个字符串,则依次对函数LeftShiftOne执行m次即可。代码如下: 时间复杂度:将一个字符移动到尾部需要n次操作,如果要移动m个字符,则需要操作m * n次。 阅读全文
posted @ 2017-09-22 21:41 immjc 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: 写出给定数组的全排列。使用递归的思想 思路:将 阅读全文
posted @ 2017-09-21 10:14 immjc 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us 阅读全文
posted @ 2017-09-20 10:31 immjc 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2017-09-19 22:43 immjc 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is define 阅读全文
posted @ 2017-09-19 21:40 immjc 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may a 阅读全文
posted @ 2017-09-19 17:41 immjc 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2017-09-12 16:25 immjc 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. 阅读全文
posted @ 2017-09-12 11:22 immjc 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the ave 阅读全文
posted @ 2017-09-11 23:14 immjc 阅读(575) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 37 下一页