Fork me on GitHub

04 2017 档案

摘要:Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutati 阅读全文
posted @ 2017-04-30 17:18 hellowOOOrld 阅读(538) 评论(0) 推荐(0)
摘要:Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1 阅读全文
posted @ 2017-04-30 13:17 hellowOOOrld 阅读(384) 评论(0) 推荐(0)
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文
posted @ 2017-04-30 11:45 hellowOOOrld 阅读(189) 评论(0) 推荐(0)
摘要:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given intege 阅读全文
posted @ 2017-04-29 22:10 hellowOOOrld 阅读(137) 评论(0) 推荐(0)
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul 阅读全文
posted @ 2017-04-28 23:04 hellowOOOrld 阅读(272) 评论(0) 推荐(0)
摘要:最近需要得到某个文件夹下所有文件名,于是就上网上查了查,得到如下的解决方案最多: 而且查到的最早的版本是这个:http://blog.csdn.net/cxf7394373/article/details/7195661. 但是放到我自己vs里却总是不行,运行到 就崩溃。 原因自己电脑系统为win1 阅读全文
posted @ 2017-04-28 20:28 hellowOOOrld 阅读(791) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu 阅读全文
posted @ 2017-04-26 21:29 hellowOOOrld 阅读(155) 评论(0) 推荐(0)
摘要:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell,where "adjacen 阅读全文
posted @ 2017-04-23 11:22 hellowOOOrld 阅读(227) 评论(0) 推荐(0)
摘要:Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtr 阅读全文
posted @ 2017-04-23 11:16 hellowOOOrld 阅读(318) 评论(0) 推荐(0)
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer,say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of m 阅读全文
posted @ 2017-04-23 11:14 hellowOOOrld 阅读(467) 评论(0) 推荐(0)
摘要:Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing inthe integer n and is grea 阅读全文
posted @ 2017-04-09 14:17 hellowOOOrld 阅读(249) 评论(0) 推荐(0)
摘要:There is a brick wall in front of you. The wall is rectangular and has several rows of bricks.The bricks have the same height but different width. You 阅读全文
posted @ 2017-04-09 13:34 hellowOOOrld 阅读(1429) 评论(0) 推荐(0)
摘要:Given a string, you need to reverse the order of characters in each word within a sentence whilestill preserving whitespace and initial word order.Exa 阅读全文
posted @ 2017-04-09 13:23 hellowOOOrld 阅读(482) 评论(0) 推荐(0)
摘要:Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an inte 阅读全文
posted @ 2017-04-08 23:26 hellowOOOrld 阅读(229) 评论(0) 推荐(0)
摘要: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 leading 阅读全文
posted @ 2017-04-08 20:59 hellowOOOrld 阅读(215) 评论(0) 推荐(0)
摘要:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After remo 阅读全文
posted @ 2017-04-08 19:58 hellowOOOrld 阅读(161) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to 阅读全文
posted @ 2017-04-08 17:12 hellowOOOrld 阅读(192) 评论(0) 推荐(0)
摘要:Reverse a singly linked list. 两种办法: 1.头插法。 2.递归。 参考: https://discuss.leetcode.com/topic/13317/accepted-c-solutions-both-iteratively-and-recursively 阅读全文
posted @ 2017-04-08 14:44 hellowOOOrld 阅读(175) 评论(0) 推荐(0)
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5 阅读全文
posted @ 2017-04-08 12:46 hellowOOOrld 阅读(398) 评论(0) 推荐(0)
摘要:Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your function s 阅读全文
posted @ 2017-04-07 21:11 hellowOOOrld 阅读(880) 评论(0) 推荐(0)
摘要: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->3-> 阅读全文
posted @ 2017-04-07 18:55 hellowOOOrld 阅读(153) 评论(0) 推荐(0)
摘要: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? 思路:先翻转再对换 1 阅读全文
posted @ 2017-04-07 09:35 hellowOOOrld 阅读(107) 评论(0) 推荐(0)
摘要: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-> 阅读全文
posted @ 2017-04-06 16:36 hellowOOOrld 阅读(169) 评论(0) 推荐(0)
摘要: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-04-06 15:44 hellowOOOrld 阅读(117) 评论(0) 推荐(0)
摘要: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, you 阅读全文
posted @ 2017-04-06 14:53 hellowOOOrld 阅读(112) 评论(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 阅读全文
posted @ 2017-04-05 17:36 hellowOOOrld 阅读(119) 评论(0) 推荐(0)
摘要:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]] 思路: 阅读全文
posted @ 2017-04-04 23:43 hellowOOOrld 阅读(177) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new lengthDo not allocate extra space for 阅读全文
posted @ 2017-04-04 19:02 hellowOOOrld 阅读(163) 评论(0) 推荐(0)
摘要:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recur 阅读全文
posted @ 2017-04-04 17:34 hellowOOOrld 阅读(161) 评论(0) 推荐(0)
摘要:Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals:"Gold Medal", "Silv 阅读全文
posted @ 2017-04-04 15:40 hellowOOOrld 阅读(320) 评论(0) 推荐(0)
摘要:Determine whether an integer is a palindrome. Do this without extra space. 思路: 判断整数是否为回文数。首先负数不行,举例,假如整数为12345,那么它的反转为54321,与原值不相等,返回false。 假如整数为12321 阅读全文
posted @ 2017-04-03 22:04 hellowOOOrld 阅读(175) 评论(0) 推荐(0)