SIMPLE JAVA SOLUTION BEATS 100% OF JAVA SUBMISSION O(N) TIME COMPLEXITY👍👍👍❤
IntuitionTO FIND THE MINIMU SUM BEATS 100% OF JAVA SUBMISSION❤😍😍ApproachSIMPLE LINER SEARCHComplexity
Time complexity:
O(N)
Space complexity:
O(1)Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
TO FIND THE MINIMU SUM BEATS 100% OF JAVA SUBMISSION❤😍😍
# Approach
<!-- Describe your approach to solving the problem. -->
SIMPLE LINER SEARCH
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)
# Code
```java []
class Solution {
    public int minElement(int[] nums) {
        for(int i=0; i<nums.length;i++){
            nums[i]=findSum(nums[i]);

        }
        return minimum(nums);
    }

    static int minimum(int[] arr){
        int min=Integer.MAX_VALUE;
        for(int i=0;i<arr.length;i++){
            if(arr[i]<min){
                min=arr[i];
            }
        }
        return min;
    }

    static int findSum(int num){
        int sum=0;
        while(num>0){
            int val=num%10;
            sum+=val;
            num=num/10;
        }
        return sum;
    }
}
```
['Java']