Skip to content

Commit

Permalink
Added codes for 14 June
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanmay-312 committed Jun 14, 2024
1 parent 9b4794d commit 1b53c78
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
37 changes: 37 additions & 0 deletions GeeksForGeeks/June/14-6-24/GFG.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//{ Driver Code Starts
//Initial Template for Java
import java.util.*;
import java.io.*;
class GFG {
public static void main(String args[]) throws IOException {
BufferedReader read =
new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(read.readLine());
while (t-- > 0) {
int n = Integer.parseInt(read.readLine());
Solution ob = new Solution();

System.out.println(ob.armstrongNumber(n));
}
}
}
// } Driver Code Ends


//User function Template for Java
class Solution
{
static String armstrongNumber(int n)
{
// code here
int x = n;
int result = 0;
while(x > 0)
{
result += Math.pow((x%10), 3);
x = x/10;
}

return result==n ? "Yes":"No";
}
}
2 changes: 2 additions & 0 deletions GeeksForGeeks/June/14-6-24/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Time complexity - O(n)
Space complexity - O(1)
2 changes: 2 additions & 0 deletions LeetCode/June/14-6-24/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Time complexity - O(n*logn)
Space complexity - O(1)
18 changes: 18 additions & 0 deletions LeetCode/June/14-6-24/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution
{
public int minIncrementForUnique(int[] nums)
{
int ans = 0;
int min = 0;

Arrays.sort(nums);

for (int num : nums)
{
ans += Math.max(min - num, 0);
min = Math.max(min, num) + 1;
}

return ans;
}
}

0 comments on commit 1b53c78

Please sign in to comment.