Find th Difference
Given two strings s
and t
which consist of only lowercase letters.
String t
is generated by random shuffling string s
and then add one more letter at a random position.
Find the letter that was added in t
.
Example:
1  Input: 
1  /** 
Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.
Example 1:
1  Input: [1,3,4,2,2] 
Example 2:
1  Input: [3,1,3,4,2] 
`
Note:
 You must not modify the array (assume the array is read only).
 You must use only constant, O(1) extra space.
 Your runtime complexity should be less than O(n2).
 There is only one duplicate number in the array, but it could be repeated more than once.
1  /** 
First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have n versions [1, 2, …, n] and you want to find out the first bad one, which causes all the following ones to be bad.
You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.
Example 1:
1 

1  /** 
First Missing Positive
Given an unsorted integer array, find the smallest missing positive integer.
Example 1:
1  Input: [1,2,0] 
Example 2:
1  Input: [3,4,1,1] 
Example 3:
1  Input: [7,8,9,11,12] 
First Unique Character in a String
Given a string, find the first nonrepeating character in it and return it’s index. If it doesn’t exist, return 1.
Examples:
1  s = "leetcode" 
1  /** 