Current streak:
3 days
Longest streak:
4 days
Less
More
public class Solution {
public static Node firstNode(Node head) {
// Write your code here.
if(head == null || head.next ==null){
return null;
}
Node ptr = head;
ArrayList<Node> hm = new ArrayList<>();
while(head !=null && !hm.contains(head)){
hm.add(head);
if(hm.contains(head.next)){
return head.next;
}
head = head.next;
}
return null;
}
}
public class Solution {
public static boolean isAnagram(String str1, String str2) {
//Your code goes here
if(str1.length() != str2.length()){
return false;
}
char[] ch1 = str1.toCharArray();
char[] ch2 = str2.toCharArray();
Arrays.sort(ch1);
Arrays.sort(ch2);
String s1 = new String(ch1);
String s2 = new String(ch2);
if(s1.equals(s2))
return true;
return false;
}
}
public class Solution {
public static int[] moveZeros(int n, int []a) {
// Write your code here.
int[] arr = new int[n];
int count =0;
int j=0;
for(int i=0;i<n;i++){
if(a[i]==0){
count ++;
continue;
}
else{
arr[j]=a[i];
j++;
}
}
for(int i=0;i<count;i++){
arr[i+j]=0;
}
return arr;
}
}