ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

C++±à³Ì£¬Êý¾Ý½á¹¹£¬Ëã·¨ÀàÃæÊÔÌ⼯(6)(¶þ)
2014-11-24 01:26:01 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:257´Î
Tags£º±à³Ì Êý¾Ý½á¹¹ Ëã·¨ ÊÔÌ⼯
nimum number of days such that each employee can attend the event at least twice. Write an algorithm (there is apparently an O(n) algorithm for this).


ÏÈ°´½áÊøµÄʱºòÅÅÐò£¬È»ºóÒÀ´ÎÑ¡È¡



162. Search in skip list


TO LEARN



163. ¸ø¶¨Ò»¸östring£¬¿ÉÒÔÈÎÒâɾ³ýÆäÖеÄchar,ÒÔʹµÄʣϵÄstring³ÉΪpalindrome,Çó×µÄÕâÑùµÄpalindrome¡£ÎÊÓÐɶdpËã·¨¿ÉÒԽ⣿


ÓëreverseÇólongest common subsequence



164. °ÑÒ»¸öÓдóд×ÖĸºÍСд×ÖĸµÄ×Ö·û´®±ä»»³ÉСд×ÖĸÔÚÇ°Ãæ´óд×ÖĸÔÚºóÃæµÄ×Ö·û´®


ÂÔ, partition



165. ¸øºÜ¶àdate ranges,Ò»¸öarray, ÿ¸ödate rangeÓпªÊ¼ÈÕÆںͽáÊøÈÕÆÚ£¬ÅжÏÁ¬Ðø²»Á¬Ðø


CODE



166. ʵÏÖhash±í


CODE



167. ÅжÏÁ½¶þ²æÊ÷È«µÈ£¨ÔÚ¿ÉÒÔ½»»»×óÓÒ×ÓÊ÷µÄÌõ¼þÏ£©£¬½øÒ»²½¸ø³öÐèÒª¶àÉٴν»»»¡£


CODE



168. Ò»¸öNxN¾ØÕó£¬Ã¿¸ö¸ñ×ÓÓÐÒ»¸öÕûÐÍÊý£¬´Ó×óÉϽǵ½ÓÒϽÇÕÒÒ»Ìõ·¾¶Ê¹µÃ¾­¹ýµÄ¸ñ×ÓÊý×ÖºÍ×î´ó¡£Ö»ÄÜÏòÓÒºÍÏÂÒƶ¯¡£Ê±¼ä¸´ÔӶȣ¬ÈçºÎÓÅ»¯¡£


DP£¬¸´ÔÓ¶ÈO(N*N)



169. ÏÖÔÚ¼ÙÉèÓÐÒ»¶ÑÕûÊýÊý×飬ÓÐÒ»¸öflipº¯Êý£¬½ÓÊÜÒ»¸öÊý×éϱêiΪ²ÎÊý£¬×÷ÓÃÊǽ«Êý×éindex ´Ó0µ½iµÄÔªËØ·´×ª¡£eg. ¼ÙÉèÊý×éΪ5, 6, -1, 3, 2, Èç¹ûµ÷ÓÃflip(3)£¬ÄÇô¾Í½«Êý×éϱê0, 1, 2, 3·´×ª£¬Êý×é±äΪ 3, -1, 6, 5, 2¡£ÎÊ£ºÖ»Ê¹ÓÃflipº¯Êý(²»ÄÜÖ±½ÓÓÃswap»òÊý×éϱê²Ù×÷[]µÈ¶ÔÊý×é½øÐÐÐÞ¸Ä)£¬À´¶Ô¸ÃÊý×éÅÅÐò¡£


IDEA£ºÃ¿×öÁ½´Îflip½«µ±Ç°×î´óµÄitem·Åµ½Î»ÉÏ


CODE



170. Ò»¸ö´óСΪNµÄÊý×飬ÆäÖÐÓÐN-1¸ö²»Í¬µÄÕûÊý£¬·¶Î§´Ó0-N, ÎÊÕÒ³ömissingµÄÄǸö
ÕûÊý¡£È»ºóÓÖÀ©Õ¹£¬ÎÊÈç¹ûÓÐk¸ömissing£¬Èç¹ûÓÃO(1)spaceÈ¥ÕÒ³öÀ´¡£


IDEA£º½«ÕûÊýi·Åµ½ÊýµÄµÚiλÉÏ


CODE



171. Suppose we have a stream of web clicks. Now you need to provide at any time the count of web clicks during the past 1 minute. To be specific, you get informed whenever a web click happens. You need to provide a function ¡°getCount()¡± such that once called, return the count of clicks during the past 1 minute. The solution will be both constant in time and space.


ÓÃÒ»¸öcircular bufferÀ´±£´æÿһÃëµÄclickÊý£¬ÔÙά»¤Ò»¸ötotalÊý¼´¿É¡£



172. Ò»¸öÓÐÐòÐòÁУ¬´Óij¸öµØ·½rotate£¬ÇóÔÚrotateµÄλÖ㬱ÈÈç 1 3 5 0 0 0£¬ÄÇôrotateµÄλÖÃÊÇ5£¬ËûºóÀ´Ö»ÓÃÁË5ÐоÍд³öÀ´ÁË£¬ºÜnb£¬±»bsÁË~~
173. ¶þ·Öͼ×î´óÆ¥Åä


ÂÔ¡£¡£¡£



174. [Facebook] implement copy-on-write string class.


TODO



175. ¸øÄãn¸öÊý×Öa1,a2¡­an£¬±íʾ×ø±êÉÏÃ棨i£¬ai£©¸öµã£¬i£½1..n£¨i£¬ai£©µ½£¨i£¬0£©¹²n¸öÏ߶Σ¬´ÓÖÐÌôÁ½Ìõ£¬ºÍxÖáÒ»Æð¹¹³ÉÒ»¸öÈÝÆ÷£¬ÈÃÈÝÆ÷ÄÜ×°µÄÒºÌåÈÝÁ¿×î´ó(ÈÝÆ÷²»ÄÜÇãб)¡£


Çî¾Ù£¿¡£¡£¡£



176. Describe an algorithm that takes an unsorted array of axis©\aligned rectangles and
returns any pair of rectangles that overlaps, if there is such a pair. Axis-aligned means that all the rectangle sides are either parallel or perpendicular to the x©\ and y©\axis. You can assume that each rectangle object has two variables in it: the x©\y coordinates of the upper©\left corner and the bottom©\right corner.


Çî¾Ù£¿¡£¡£¡£



177. Given a list of intervals, ±ÈÈç (10,20),(30,50)¡­,and a target interval,
±ÈÈç(18,35) ÕÒÓжàÉÙoverlap.


http://programmers.stackexchange.com/questions/64132/interestin


INTERVAL TREE



178. ¸ø¶¨Ò»¸öinteger array, a1,a2¡­an, ÕÒ³öËùÓÐa,b,c,dʹµÃa+b = c+d. ºÜÈÝÒ×ÕÒµ½O(n^2)¿Õ¼ä£¬O(n^2)ʱ¼äµÄËã·¨£¬²»ÖªµÀÓÐûÓиü¿ì¸üºÃµÄ¡£


Èç¹ûËùÓеÄÊý¶¼ÏàµÈ£¬ÄÇÖÁÉÙÐèÒªO(n^2)ʱ¼ä¸´ÔӶȡ£ÁíÍâÅÅÐòºó£¬¶þÖØÑ­»·¼ÓÁ½Í·É¨Ã裬²»ÐèÒª¶îÍâµÄ¿Õ¼ä¸´ÔÓ¶ÈÁË¡£



179. n¸öÇò, nºÜ´ó > 1 billion, k¸öÑÕÉ«, kÏà¶ÔС£¬ ±ÈÈç10. ÒªÇóin space sort×îefficientµÄ×ö·¨ °×°åcoding. £¨hint, k<< n ËùÒÔ×îºóËã·¨ÕùÈ¡±Ènlog(n)С)
¸ÃÌâµÄµÚ¶þÎÊ k = 1000 ʵÏÖ±Ènlogn ¸üefficientµÄin spaceµÄËã·¨


¼û138Ìâ



180. If the Fibonacci series is 1,2,3,5,8,13,¡­.. then 10 can be written as 8 +
2 ==> 10010 and 17 can be written as 13 + 3 + 1 ==> 100101. The Question was, given n, I need to get all possible representations of n in Fibonacci Binary Number System. as 10 = 8 + 2 ==> 10010 also 10 = 5 + 3 + 2 ==> 1110 (Zeckendorf¡¯s theorem)


Èç¹ûÒªµÃµ½ËùÓеÄ×éºÏ£¬ÏȼÆËã³ö¸ÃÊý·¶Î§ÄÚµÄFibonacciÊý£¬ÔÙµ±³ÉÕÒÁãÎÊÌâÀ´¼ÆËã¾Í¿ÉÒÔÁË¡£


Zeckendorf¡¯s theorem:


Every positive integer can be represented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive Fibonacci numbers.


Ê×Ò³ ÉÏÒ»Ò³ 1 2 ÏÂÒ»Ò³ βҳ 2/2/2
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£º.net³ÌÐòÔ±ÃæÊÔÊÔÌâ(Ò») ÏÂһƪ£ºC++±à³Ì£¬Êý¾Ý½á¹¹£¬Ëã·¨ÀàÃæÊÔÌâ..

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿