Skip to content

Commit

Permalink
Added codes for 13 June
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanmay-312 committed Jun 13, 2024
1 parent dfe21d1 commit 9b4794d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
45 changes: 45 additions & 0 deletions GeeksForGeeks/June/13-6-24/GFG.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//{ Driver Code Starts
//Initial Template for Java

import java.io.*;
import java.util.*;
class GfG
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
int n = sc.nextInt();
Solution ob = new Solution();
System.out.println(ob.padovanSequence(n));
}
}
}
// } Driver Code Ends


//User function Template for Java

class Solution
{
int mod = 1000000007;
public int padovanSequence(int n)
{
//code here.
if (n < 3)
return 1;

int a=1, b=1, c=1, d=1;
for (int i=3; i<=n; i++)
{
d = (a + b)%mod;
a = b;
b = c;
c = d;
}
return d;
}

}
2 changes: 2 additions & 0 deletions GeeksForGeeks/June/13-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/13-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(logn)
15 changes: 15 additions & 0 deletions LeetCode/June/13-6-24/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution
{
public int minMovesToSeat(int[] seats, int[] students)
{
int res = 0;

Arrays.sort(seats);
Arrays.sort(students);

for (int i = 0; i < seats.length; i++)
res += Math.abs(seats[i] - students[i]);

return res;
}
}

0 comments on commit 9b4794d

Please sign in to comment.