A proof is a method of ascertaining a proof
- experimenting/observing
- sampling, counter example
- judge, jury
- word of God
- authority, god
A mathematical proof is a verification of a proposition by a chain of logical deduction from a set of axioms
- a proposition is a statement that is either true or false
- an axiom is a proposition that is "assumed" to be true
- 1D array find a peak solution
func findPeakElement(nums []int) int {
return findPeakUtil(nums, 0, len(nums)-1, len(nums))
}
func findPeakUtil(nums []int, low, high int, length int) int {
mid := low + (high - low) / 2
if (mid == length - 1 || nums[mid] >= nums[mid + 1]) && (mid == 0 || nums[mid] >= nums[mid - 1]) {
return mid
} else if nums[mid] < nums[mid + 1] {
return findPeakUtil(nums, mid+1, high, length)
} else {
return findPeakUtil(nums, low, mid-1, length)
}
return -1
}