算法
文章平均质量分 54
jeanheo
这个作者很懒,什么都没留下…
展开
-
RSA非对称加密算法详解
加密技术加密技术是对信息进行编码和解码的技术,编码是把原来可读信息(又称明文)译成代码形式(又称密文),其逆过程就是解码(解密),加密技术的要点是加密算法,加密算法可以分为三类: 1. 对称加密 2. 非对称加密 3. 不可逆加密对称加密算法加密过程: 将明文分成N个组,然后对各个组进行加密,形成各自的密文,最后把所有的分组密文进行合并,形成最终的密文。优点: 算法公开、计算量小、加密原创 2016-12-11 23:10:50 · 37546 阅读 · 0 评论 -
Count 1 in Binary 解题报告
Count 1 in BinaryDescriptionCount how many 1 in binary representation of a 32-bit integer. Noitce If you are using Java or Python,please use characters array instead of string.ExampleGiven 32, re原创 2017-04-25 14:52:17 · 716 阅读 · 0 评论 -
Reverse Linked List 解题报告
Reverse Linked ListDescriptionReverse a linked list.ExampleFor linked list 1->2->3, the reversed linked list is 3->2->1ChallengeReverse it in-place and in one-pass实现思路注意边界条件head和head.next。定义cur = hea原创 2017-04-26 00:16:41 · 383 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array 解题报告
Find Minimum in Rotated Sorted ArrayDescriptionSuppose a sorted array 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). Notice You may assume no d原创 2017-04-26 00:23:40 · 323 阅读 · 0 评论 -
Construct Binary Tree from Preorder and Inorder Traversal 解题报告
Construct Binary Tree from Preorder and Inorder TraversalDescriptionConstruct Binary Tree from Preorder and Inorder Traversal Notice You may assume that duplicates do not exist in the tree.Examp原创 2017-04-26 10:47:15 · 411 阅读 · 0 评论 -
Search a 2D Matrix 解题报告
Search a 2D MatrixDescriptionWrite 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 from left to right.原创 2017-04-26 11:05:59 · 452 阅读 · 0 评论 -
Implement Queue by Two Stacks 解题报告
Implement Queue by Two StacksDescriptionAs the title described, you should only use two stacks to implement a queue’s actions.The queue should support push(element), pop() and top() where pop is pop th原创 2017-04-26 10:56:24 · 898 阅读 · 0 评论 -
Partition Array by Odd and Even 解题报告
Partition Array by Odd and EvenDescriptionPartition an integers array into odd number first and even number second.ExampleGiven [1, 2, 3, 4], return [1, 3, 2, 4]ChallengeDo it in-place.实现思路可以利用快排的思路,左原创 2017-04-26 11:20:33 · 488 阅读 · 0 评论 -
Search a 2D Matrix II 解题报告
Search a 2D Matrix IIDescriptionWrite an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it.This matrix has the following properties:Integers in each row are原创 2017-04-26 11:16:16 · 650 阅读 · 0 评论 -
Backpack 解题报告 背包问题深入浅出
BackpackDescriptionGiven n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack? ExampleIf we have 4 items with size [2, 3, 5, 7], the backpack size is 1原创 2017-04-26 13:04:20 · 1852 阅读 · 0 评论 -
Backpack II 解题报告
Backpack IIDescriptionGiven n items with size Ai and value Vi, and a backpack with size m. What’s the maximum value can you put into the backpack?NoticeYou cannot divide item into small pieces and the原创 2017-04-26 13:21:01 · 764 阅读 · 0 评论 -
Longest Common Substring 解题报告
Longest Common SubstringDescriptionGiven two strings, find the longest common substring.Return the length of it.NoticeThe characters in substring should occur continuously in original string. This is d原创 2017-04-26 14:21:53 · 1296 阅读 · 0 评论 -
Longest Common Subsequence 解题报告
Longest Common SubsequenceDescriptionGiven two strings, find the longest common subsequence (LCS).Your code should return the length of LCS.ClarificationWhat’s the definition of Longest Common Subseque原创 2017-04-26 14:35:07 · 1546 阅读 · 0 评论 -
Kth Largest Element 解题报告
Kth Largest ElementDescriptionFind K-th largest element in an array.NoticeYou can swap elements in the arrayExampleIn array [9,3,2,4,8], the 3rd largest element is 4.In array [1,2,3,4,5], the 1st large原创 2017-05-12 01:46:37 · 1111 阅读 · 0 评论 -
Space Replacement 解题报告
Space ReplacementDescriptionWrite a method to replace all spaces in a string with %20. The string is given in a characters array, you can assume it has enough space for replacement and you are given th原创 2017-04-25 14:44:29 · 690 阅读 · 0 评论 -
Fibonacci 解题报告
FibonacciDescriptionFind the Nth number in Fibonacci sequence.A Fibonacci sequence is defined as follow:The first two numbers are 0 and 1.The i th number is the sum of i-1 th number and i-2 th number.原创 2017-04-25 14:36:28 · 846 阅读 · 0 评论 -
Fizz Buzz 解题报告
Fizz BuzzDescriptionGiven number n. Print number from 1 to n. But:when number is divided by 3, print "fizz".when number is divided by 5, print "buzz".when number is divided by both 3 and 5, print "fi原创 2017-04-25 14:02:34 · 602 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array 解题报告
Find Minimum in Rotated Sorted ArrayDescriptionSuppose a sorted array 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).Find the minimum element.Notice原创 2017-05-10 22:34:41 · 400 阅读 · 0 评论 -
Subtree 解题报告
SubtreeDescriptionYou have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1. NoticeA tree T2 is a subtree原创 2017-05-10 22:47:47 · 372 阅读 · 0 评论 -
Remove Nth Node From End of List 解题报告
Remove Nth Node From End of ListDescriptionGiven a linked list, remove the nth node from the end of list and return its head.NoticeThe minimum number of nodes in list is n.ExampleGiven linked list: 1->原创 2017-05-10 22:55:49 · 536 阅读 · 0 评论 -
Print Numbers by Recursion 解题报告
Print Numbers by RecursionDescriptionPrint numbers from 1 to the largest number with N digits by recursion.Notice It’s pretty easy to do recursion like:recursion(i) { if i > largest number:原创 2017-05-10 23:16:42 · 483 阅读 · 0 评论 -
Fast Power 解题报告
Fast PowerDescriptionCalculate the an % b where a, b and n are all 32bit integers.ExampleFor 231 % 3 = 2 For 1001000 % 1000 = 0ChallengeO(logn)实现思路最直接的思路是直接进行n次循环,每次执行: a = (a*a) % b运算,时间复杂度为o(n)。 除原创 2017-05-11 00:15:29 · 696 阅读 · 0 评论 -
Binary Tree Path Sum 解题报告
Binary Tree Path SumDescriptionGiven a binary tree, find all paths that sum of the nodes in the path equals to a given number target.A valid path is from root node to any of the leaf nodes.ExampleGiven原创 2017-05-11 00:23:37 · 1348 阅读 · 0 评论 -
Binary Tree Level Order Traversal 解题报告
Binary Tree Level Order TraversalDescriptionGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).ExampleGiven binary tree {3,9,20,#,#,15,原创 2017-05-11 00:30:04 · 343 阅读 · 0 评论 -
Copy List with Random Pointer 解题报告
Copy List with Random PointerDescriptionA linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list原创 2017-05-11 01:00:16 · 484 阅读 · 0 评论 -
Min Stack 解题报告
Min StackDescriptionImplement a stack with min() function, which will return the smallest number in the stack.It should support push, pop and min operation all in O(1) cost.Noticemin operation will nev原创 2017-05-11 10:58:03 · 536 阅读 · 0 评论 -
Majority Number 解题报告
Majority NumberDescriptionGiven an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it.It should support push, pop and min operation all in原创 2017-05-11 11:11:33 · 386 阅读 · 0 评论 -
Maximum Subarray 解题报告
Maximum SubarrayDescriptionGiven an array of integers, find a contiguous subarray which has the largest sum.NoticeThe subarray should contain at least one number.ExampleGiven the array [−2,2,−3,4,−1,2,原创 2017-05-12 00:20:04 · 492 阅读 · 0 评论 -
getIntersectionNode 解题报告
getIntersectionNodeDescriptionWrite a program to find the node at which the intersection of two singly linked lists begins.NoticeIf the two linked lists have no intersection at all, return null.The li原创 2017-05-12 00:47:30 · 1044 阅读 · 0 评论 -
Reorder array to construct the minimum number 解题报告
Reorder array to construct the minimum numberDescriptionConstruct minimum number by reordering a given non-negative integer array. Arrange them such that they form the minimum number.NoticeThe result m原创 2017-05-12 00:54:51 · 939 阅读 · 0 评论 -
Digit Counts 解题报告
Digit CountsDescriptionCount the number of k’s between 0 and n. k can be 0 - 9.Exampleif n = 12, k = 1 in[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]we have FIVE 1’s (1, 10, 11, 12)实现思路本题最简单的实现,就是遍历一个1~n原创 2017-05-18 21:46:24 · 1996 阅读 · 1 评论