随笔分类 - algorithm & data structure
摘要:题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2). You are given a targe...
阅读全文
摘要:题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not poss...
阅读全文
摘要:题目:You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concaten...
阅读全文
摘要:题目:Divide two integers without using multiplication, division and mod operator.思路分析二分法.将除数不断增倍,而结果同样扩大两倍,直到除数的值大于被除数.然后再利用被除数减去除数最后增长到小于被除数的值,递归求出结果.例...
阅读全文
摘要:题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo...
阅读全文
摘要:Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a...
阅读全文
摘要:题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your al...
阅读全文
摘要:题目:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"(((...
阅读全文
摘要:题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telep...
阅读全文
摘要:题目:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Ele...
阅读全文
摘要:题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.题目分析: 看了半天,题目都没看懂,都不知道了roman numeral...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目 Given a string s,find the longest palindromic substring in S.You may assume that the maximum length of S is 1000,and there exist one unique longes...
阅读全文
摘要:题目: There are two sorted arrays A and B of size m and n respectively.Find the Median of two sorted arrays.The overall run time complexity should be O(...
阅读全文
摘要:题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1065思路分析:1)对a+b造成的long long 类型的数据溢出进行特殊处理: a>0 && b>0 && a+b=0 :则a+b必小于c 1 #include 2 #include 3 ...
阅读全文
摘要:题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1064思路分析:1)先对数组排好序。2)采用中序遍历的方式,将排好序的元素逐个插入在完全二叉树中。3)利用完全二叉树采用数组存储的方式,对于结点序号为index的结点,其左孩子结点2*i,右孩子结...
阅读全文
浙公网安备 33010602011771号