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

TOP

C++±à³Ì£¬Êý¾Ý½á¹¹£¬Ëã·¨ÀàÃæÊÔÌ⼯(7)(¶þ)
2014-11-24 01:26:01 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:225´Î
Tags£º±à³Ì Êý¾Ý½á¹¹ Ëã·¨ ÊÔÌ⼯
tegers only, and what happens when it is mixed with positive and negative integers


ÏßÐÔɨÃè²¢¼ÆËãһϼ´¿É¡£Õý¸ºÊýÊÇ·ñÓйØϵ£¿



202. Ò»¸öarraylist,ÀïÃæÓкܶàstring,ËüÃÇ°´ÕÕδ֪µÄalphabetical˳ÐòÅÅÁÐ,ÒªÇóÊä³öËùÓпÉÄܵÄalphabetical order,(ºóÀ´ÓÖÎÊÁËÈçºÎÅжÏÊÇ·ñÓÐconflict)
Àý×Ó:it is a good day today,
it is a good day


Á½Á½±È½ÏÕÒµÚÒ»¸ö²»Í¬¼´¿É¡£


ÅжÏÊÇ·ñÓгåÍ»£¿Õû¸ö¹ØϵÐγÉÒ»¸öͼ£¬Õâ¸öͼӦ¸ÃÊÇÎÞ»·µÄ£¬×öÒ»´ÎDFS¼´¿É¡£



203. ÓÐÒ»¶ÑµÄ¹¤×÷,ÿ¸ö¹¤×÷ÓпªÊ¼ºÍ½áÊøʱ¼ä,¼ÙÉè±íʾΪ[2,3],[3,7]µÈµÈ,ÏÖÔÚÒªÇóÔÚ[1,n]µÄʱ¼ä¶ÎÄÚÑ¡³ö¾¡¿ÉÄܶàµÄ¹¤×÷.


Ì°ÐÄ£¬¾¡Á¿Ñ¡Ôñ½áÊøʱ¼ä×îÔçµÄ¹¤×÷¼´¿É



204. ¸øÒ»¸öÊý×é Àï±ß¶¼ÊÇÕûÊý Çó×î´ó³Ë»ýµÄÁ¬Ðø×ÓÊý×é


ÏÈ°´Áã°ÑÊý×é·Ö³ÉÈô¸É¸ö×ÓÊý×飬ÔÙÔÚ×ÓÊý×éÀïÕÒ°üº¬Å¼Êý¸ö¸ºÊýµÄ×î´óµÄ·¶Î§¡£



205. f(i,j)=2^i*5^j¸ø³öÒ»¸ö³¤¶ÈΪNµÄ(i,j)ÐòÁУ¬Ê¹µÃfÖµµÝÔö£¬i>=0,j>=0
Éèf(i,j)ÊǵÚk¸öÊýf_k, ÔòÏÂÒ»¸öÊýȡʹi+1»òÕßj+1Öмä±È½ÏСµÄÄǸö¼´¿É


206. f(N): return round(reduce(lambda x,y: int(x)+int(y), list(str(N))))/len(N) NΪÕûÊý£¬fº¯Êý·µ»ØN¸÷λÊýÖµµÄƽ¾ùÊý£¬ÏÖÔÚ¸ø³öÒ»¸öÕýÕûÊý·¶Î§[begin, end]£¬ÒªÇóµÃ³ö¸Ã·¶Î§ÖзûºÏf(N)>=7µÄÊýµÄ¼¯ºÏ£¬Ï£ÍûËã·¨¾¡¿ÉÄܱÈend-begin+1´Îtest¿ì¡£


TO LEARN£¬




207. There is a straight road with ¡®n¡¯ number of milestones. You are given an array with the distance between all the pairs of milestones in some random order. Find the position of milestones.
Example:
Consider a road with 4 milestones(a,b,c,d) :
a <¡ª 3Km ¡ª>b<¡ª 5Km ¡ª>c<¡ª 2Km ¡ª>d
Distance between a and b = 3
Distance between a and c = 8
Distance between a and d = 10
Distance between b and c = 5
Distance between b and d = 7
Distance between c and d = 2
All the above values are given in a random order say 7, 10, 5, 2, 8, 3.
The output must be 3,5,2 or 2,5,3


¶ÔÕâ¸öÊý×éÀïµÄÿһ¸öÊý£¬Èç¹ûËü²»ÄܱíʾΪ¸ÃÊý×éÀïÁ½¸öÊýÖ®ºÍ£¬ÔòÊÇÒ»¸öÒªÇóµÄÁ½¸ömilestoneÖ®¼äµÄ¾àÀë



208. ÕÒ¶þ²æÊ÷Á½¸ö×î´óµÄÏàͬ×ÓÊ÷


²»ÊǺÜÀí½âÌâÒâ¡£¡£¡£Á½Á½±È½Ï¼´¿É£¬¸´ÔÓ¶ÈO(N^2),ÈçÒª¼ÓËÙ£¬¿ÉÒÔÏȼÆËãÿ¸ö½áµãµÄÉî¶ÈºÍ×Ó½áµãÊý£¬ÏàͬÔÙ½øÐбȽϡ£



209. Given an array of elements find the largest possible number that can be formed by using the elements of the array.
eg: 10 9
ans: 910
2 3 5 78
ans: 78532
100 9
ans: 9100


ÏÈ°´ÈçϹ涨ÅÅÐò£º a > b if ab > ba,


È»ºóÔٴӸߵ½µÍÆ´½ÓÆðÀ´¼´¿É¡£



210. You have an array of 0s and 1s and you want to output all the intervals (i, j) where the number of 0s and numbers of 1s are equal. Example index = 0 1 2 3 4 5 6 7 8 array = 0 1 0 0 1 1 1 1 0 One interval is (0, 1) because there the number of 0 and 1 are equal. There are many other intervals, find all of them in linear time. How can this be done in O(n) find all intervals, not find the longest interval.


O(N)ºÃÏñ²»¿ÉÄÜ×öµ½£¬ÒòΪËùÓеÄintervals¿ÉÄܾÍÊÇO(N^2)¼¶±ðµÄ


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

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

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