Update appNew update is available. Click here to update.
About
University at Buffalo 2024
Java - Default language
My Stats
EXP gained
yellow-spark
4864
Level
5 (Champion)
Community stats
Discussions
0
Upvotes
0
Know more
75
Total problems solved
56
Easy
18
Moderate
1
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

3 days

Longest streak:

4 days

Less

More

Achievements
3
Ronin
Topics
Arrays
Strings
+ 1 more
Discussions
Java Solution using ArrayList
Interview problems
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;
    }
}
profile
Chirayu Sanghvi
Published On 28-Nov-2023
19 views
0 replies
0 upvotes
Easy Java Solution, performed better than 90 % submission here.
Interview problems
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;
    }
}
profile
Chirayu Sanghvi
Published On 14-Oct-2023
64 views
0 replies
0 upvotes
Java Answer, performed better than 99.6 %
Interview problems
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; 
    }
}
profile
Chirayu Sanghvi
Published On 22-Sep-2023
20 views
0 replies
0 upvotes