Add coding exercises for Facebook interviews
Add attempts at solving coding problems to Briefcase.
This commit is contained in:
		
							parent
							
								
									d2d772e43e
								
							
						
					
					
						commit
						aa66d9b83d
					
				
					 66 changed files with 2994 additions and 0 deletions
				
			
		
							
								
								
									
										15
									
								
								scratch/facebook/largest-contiguous-sum.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								scratch/facebook/largest-contiguous-sum.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| def find_sum(xs): | ||||
|     result = float('-inf') | ||||
|     streak = 0 | ||||
|     for x in xs: | ||||
|         result = max(result, streak, x) | ||||
|         if streak + x <= 0: | ||||
|             streak = x | ||||
|         else: | ||||
|             streak += x | ||||
|     return result | ||||
| 
 | ||||
| 
 | ||||
| x = [2,-8,3,-2,4,-10] | ||||
| assert find_sum(x) == 5 | ||||
| print("Success!") | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue