T(n)=aT(n/b)+f(n); where we can interpret n/b to mean either floor(b/n) or ceil(b/n), Then T (n) has the following asymptotic bounds: 1. If f (n)= O(nlogb a-c) for some constant c> 0, then T (n)=Θ(nlogb a)2.If f (n)= Θ(nlogb a), then T (n)=Θ(nlogb a…
问题: There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example1:nums1 = [1, 3]nums2 = [2]The median is 2.0Example2:nums1 = [1, 2]n…
问题: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 官方难度: Hard 翻译: 合并k个已排序的链表,得到一个新的链表并且返回其第一个节点.分析并阐述其复杂度. 这是No.021(Merge Two Sorted Lists)的深入研究. 可以借鉴归并排序的思想,对于长度为k的数组,依次进行二路归并,返回这两个链表合并之后的头结点(利用No.…
Cognition math based on Factor Space Wang P Z1, Ouyang H2, Zhong Y X3, He H C4 1Intelligence Engineering and Math Institute, Liaoning Technical Univ. Fuxin, Liaoning, 123000, China 2Jie Macroelectronics co. Ltd, Shanghai, 200000, China 3 I & CE Colle…
simple and common parallel algorithm building block is the all-prefix-sums operation. In this chapter, we define and illustrate the operation, and we discuss in detail its efficient implementation using NVIDIA CUDA. Blelloch (1990) describes all-pref…
Awesome Courses  Introduction There is a lot of hidden treasure lying within university pages scattered across the internet. This list is an attempt to bring to light those awesome courses which make their high-quality material i.e. assignments, lect…
A Gentle Guide to Machine Learning Machine Learning is a subfield within Artificial Intelligence that builds algorithms that allow computers to learn to perform tasks from data instead of being explicitly programmed. Got it? We can make machines lear…
问题: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P   A   H   N A P L S I I G Y   I   R And then read line by line: &q…
问题: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 官方难度: Medium 翻译: 给定一个字符串S,找出最长回文子串,你可以假定字符串的最大长度为1000,并且只有一个最长回文子串. 例子:…
问题: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array…
问题: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only…
问题: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list…
问题: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ "((()))", "(()())", "(())()", "()(())", "()()()" ]…
问题: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 官方难度: Easy 翻译: 合并2个已排序的链表,得到一个新的链表并且返回其第一个节点. 考虑输入节点存在null的情况,直接返回另一个节点. 节点的定义在No.002(Add Two Numbers)中有…
问题: Determine whether an integer is a palindrome. Do this without extra space. 官方难度: Easy 翻译: 不使用额外空间,判断一个数是不是回文形式. 暂定负数不参与讨论. 先获取数值长度,取得对应位置的数字比较. 重点是如何取到一个整数指定位置的数字,通过(x/Math.pow(10,n-1))%10来实现. 循环至一半就可以退出. 解题代码: public static boolean isPalindrome(…
问题: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. 官方难度: Easy 翻译: 实现atoi功能,将一个字符串转化成一个整数. 提示:仔细考虑各种可能出现的情况. 补充资料: 所谓atoi,是C语言库中的一个函数,其功能如下: Requirements for atoi: The function first discards as ma…
问题: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 官方难度: Easy 翻译: 将一个整数倒转输出. 例子: 整数:123,倒转输出:321. 整数:-123,倒转输出:-321. 给定例子中,存在负数情况,将负数的输入转化成整数统一讨论,同时记录负数标志位,在返回时使用. 优先获取整数的位数,有两种方法:第一种是根据定义出发,循环将输入数字除以10,累加次数.这…
一.前言 Promises/A是由CommonJS组织制定的异步模式编程规范,有不少库已根据该规范及后来经改进的Promises/A+规范提供了实现 如Q, Bluebird, when, rsvp.js, mmDeferred, jQuery.Deffered()等. 虽然上述实现库均以Promises/A+规范作为实现基准,但由于Promises/A+是对Promises/A规范的改进和增强,因此深入学习Promises/A规范也是不可缺少的. 本文内容主要根据以下内容进行学习后整理而成,若…
问题: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]&…
问题: 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 removing the second node from the end, the linked list becomes 1->2->3->5. 官方难度: Ea…
问题: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution set must not contain duplicate quadruplets. For ex…
问题: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Example:Input:Digit string "23"Output: ["ad", "ae&…
问题: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.Return the sum of the three integers. You may assume that each input would have exactly one solution.For example, given array S = {-1…
问题: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0?Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain duplicate triplets.For example, given array S = [-1,…
问题: Write a function to find the longest common prefix string amongst an array of strings. 官方难度: Easy 翻译: 寻找一个字符串数组的最长公共前缀. 方法一: 数组长度为0,返回空字符串. 将数组第一项,作为初始的公共前缀. 从数组第二项开始进入循换,整理当前字符和当前前缀字符的长度. 以小长度的字符串为基准,从头开始逐个匹配,遇到不同的字符时,更新前缀字符. 为防止完全匹配情况,如"aa"…
问题: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. 官方难度: Easy 翻译: 将一个范围在1-3999的罗马字符,转化成整数形式. 罗马字符的规则见上一章No.012. 输入不考虑非罗马字符,或错误的罗马字符形式,如"IVI". 需要一个翻译,罗马字符-数字的映射关系的字典方法. 依次根据罗马字符累加,但是要考虑4…
问题: Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial). 官方难度: Hard 翻译: 实现正则表达式匹配字符串,支持特…
abstract :本文从各个方面讨论了泡妞与做题之间的相似之处与不同点,尽量的站在一个公平的角度阐述这一问题,所得的研究成果填补了国内外的理论空白. - 泡了一个好妞就好像做了一道难题一样快感都是相同的. - 首先这两项活动都需要耗费大量的精力,一般都是20岁左右的时候,最有激情最有精力参加这两项活动.所以参加acm的同时大多都是适婚男青年,主要人群两者基本相同. - 就像普通人一辈子泡妞的日子不过三五年,acm也有五年参赛的限制. - 假如你泡妞泡的特有成就,比如搞定了张梓琳.就好比参加了f…
1.1 What is Kerberos 1.1.1 简单介绍 Kerberos是一个用于鉴定身份(authentication)的协议, 它采取对称密钥加密(symmetric-key cryptography),这意味着密钥不会在网络上传输.在Kerberos中,未加密的密码(unencrypted password)不会在网络上传输,因此攻击者无法通过嗅探网络来偷取用户的密码. Kerberos利用对称加密和受信任的第三方(即KDC, key distribution center)来鉴别…
题目: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999. 官方难度: Medium 翻译: 给定一个范围在1-3999内的整数,将其转化成罗马数字. 补充资料: 罗马数字规则: 需要用到的罗马数字共有7个,即I(1).V(5).X(10).L(50).C(100).D(500)和M(1000).罗马数字中没有0. 一个罗马数字最多重复…