---
# System prepended metadata

title: Untitled

---

Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M).

More formally check if there exists two indices i and j such that :

i != j
0 <= i, j < arr.length
arr[i] == 2 * arr[j]

Example 1:
Input: arr = [10,2,5,3]
Output: true
Explanation: N = 10 is the double of M = 5,that is, 10 = 2 * 5.

Example 2:
Input: arr = [7,1,14,11]
Output: true
Explanation: N = 14 is the double of M = 7,that is, 14 = 2 * 7.

Example 3:
Input: arr = [3,1,7,11]
Output: false
Explanation: In this case does not exist N and M, such that N = 2 * M.

1. traverse
2. n * 2 
3. if array.contains(n*2) return 
4. return false

https://leetcode.com/contest/weekly-contest-175/problems/check-if-n-and-its-double-exist/
```
public boolean checkIfExist(int[] arr) {
    if (arr == null || arr.length <= 1) {
        return false;
    }
    
    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < arr.length; i++) {
        if (set.contains(arr[i] * 2) || set.contains(arr[i] / 2) && arr[i] % 2 == 0) {
            return true;
        }
        set.add(arr[i]);
    }
    
    return false;
    
}
```

https://leetcode.com/contest/weekly-contest-175/problems/minimum-number-of-steps-to-make-two-strings-anagram/

Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.

Return the minimum number of steps to make t an anagram of s.

An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

 

Example 1:
Input: s = "bab", t = "aba"
Output: 1
Explanation: Replace the first 'a' in t with b, t = "bba" which is anagram of s.

Example 2:
Input: s = "leetcode", t = "practice"
Output: 5
Explanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.

Example 3:
Input: s = "anagram", t = "mangaar"
Output: 0
Explanation: "anagram" and "mangaar" are anagrams.

Example 4:
Input: s = "xxyyzz", t = "xxyyzz"
Output: 0
Example 5:

Input: s = "friend", t = "family"
Output: 4


1. sort
2. traverse s, t
3. compare each char
4. count + 1 when each char is different

// "leetcode"
// "practice"
// cdeeelot
// acceiprt

int[] arr = new int[26];
charAt(i)

// [0....0] size 26
// s = [3....0] size 26
// t = [1....0] 
// traverse arr add all value in this array

```
public int minSteps(String s, String t) {
   int[] arr = new int[26];
   for (int i = 0; i < s.length(); i++) {
       arr[s.charAt(i) - 'a']++;
       arr[t.charAt(i) - 'a']--;
   }
   
   int result = 0;
   for (int i = 0; i < arr.length; i++) {
       result += arr[i];
   }
   return result;
}
```