This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include<stdio.h> | |
| #include<time.h> | |
| int sumAlgorithmA(int num) | |
| { | |
| return num*(num + 1) / 2; | |
| } | |
| int sumAlgorithmB(int num) | |
| { | |
| int sum = 0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.company; | |
| public class Main { | |
| public static int search(int[] nums, int target) { | |
| int mid, left = 0, right = nums.length-1; | |
| while(left <= right){ | |
| mid = left + (right - left)/2; | |
| if(nums[mid] == target) return mid; | |
| if(target < nums[mid]) right = mid - 1; |