码迷,mamicode.com
首页 >  
搜索关键字:算法面试    ( 461个结果
LeetCode: Subsets [078]
class Solution { public: void dfs(vector<vector >&result, vectorcombination, vector&candidates, int kth, int k, int index2add){ // 当前正在确定组合中的第kth个数,将把候选集candidates中index2add索引位的值作为第kth个数加到组合中 combination.push_back(ca...
分类:其他好文   时间:2014-06-07 01:21:47    阅读次数:220
LeetCode: Sort Colors [075]
【题目】 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, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and...
分类:其他好文   时间:2014-06-07 01:17:49    阅读次数:269
LeetCode: Combinations [077]
【题目】 Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". Note: If there is no such window in S that covers ...
分类:其他好文   时间:2014-06-05 11:14:26    阅读次数:255
LeetCode: Minimum Window Substring [076]
【题目】 Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". Note: If there is no such window in S that covers ...
分类:Windows程序   时间:2014-06-05 10:03:07    阅读次数:473
LeetCode: Rotate Image [047]
【题目】 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? 【题意】 给定一个nXn的二维矩阵,按时钟方向旋转90度,不能使用额外的数据结构 【思路】 从外向内逐层旋转...
分类:其他好文   时间:2014-05-26 05:50:25    阅读次数:266
LeetCode: Pow(x, n) [049]
【题目】 Implement pow(x, n). 【题意】 实现pow(x, n) 【思路】 最直接的思路是用一个循环,乘n次的x。 当n的值较小的时候还好,当n非常大时,时间成本就非常高。加入n=INT_MAX, 也就是21亿多次循环,你可以试想一下。 在这种情况下,我们需要快速的乘完n个x,采用尝试贪心的方法,即滚雪球方式的翻倍相乘 注意:几种特殊情况 1. n=0; 2. n<0;...
分类:其他好文   时间:2014-05-26 04:37:31    阅读次数:212
LeetCode: Rotate List [060]
【题目】 Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. 【题意】 给定一个链表L,和非负数K,要求把链表的后k个节点移到链表前 【思路】 先将指针指向指向倒数第K个节点,然后...
分类:其他好文   时间:2014-05-25 18:20:06    阅读次数:252
LeetCode: Insert Interval [056]
【题目】 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Given intervals [1,3],[6,9], insert and mer...
分类:其他好文   时间:2014-05-25 12:56:43    阅读次数:271
LeetCode: Spiral Matrix II [058]
【题目】 Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] 【题意】 给定整数n, 将1,2,3...nxn个数按螺旋旋转的方式填入n...
分类:其他好文   时间:2014-05-25 07:08:17    阅读次数:235
LeetCode: Permutation Sequence [059]
【题目】 The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123" "132" "213" "231" "312" "321" Given n and k, return the kth permutation ...
分类:其他好文   时间:2014-05-25 06:13:37    阅读次数:276
461条   上一页 1 ... 39 40 41 42 43 ... 47 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!