Unknown's avatar

شهادة حضور اليوم القرآنى بجامع الراجحى بالرياض

جمعية تحفيظ القرآن بالرياض – مكنون
شهادة حضور
تشهد إدارة الشئون التعليمية بجميعة تحفيظ القرآن الكريم بالرياض (مكنون) بأن الطالب/ عمر خميس جمال الدين شارك فى اليوم القرآنى المقام فى جامع الراجحى يوم السبت الموافق 3/12/1443 هـ سائلين الله له مزيدا من التوفيق والنجاح
مدير إدارة الشئون التعليمية

Unknown's avatar

1971. Find if Path Exists in Graph

1971. Find if Path Exists in Graph

class Solution {
    public boolean validPath(int n, int[][] edges, int source, int destination) {
        if(source == destination) return true;
        Graph g = new Graph(n);
        
        for(int i = 0 ; i < edges.length; i++){
            g.addEdge(edges[i][0],edges[i][1]);
            g.addEdge(edges[i][1],edges[i][0]);
        }
        boolean[] visited = new boolean[n];
        
        Queue<Integer> q = new LinkedList<Integer>();
        q.add(source);
        visited[source] =true;
        while(!q.isEmpty()){
            int current = q.poll();
             Iterator<Integer> i = g.adj[current].listIterator();
            while (i.hasNext())
            {
                int next = i.next();
                if(next == destination) return true;
                if (!visited[next])
                {
                    visited[next] = true;
                    q.add(next);
                   
                }
            }
            
            
        }
        
        return false;
    }
    class Graph
{
    private int V;   // No. of vertices
    private LinkedList<Integer> adj[]; //Adjacency Lists
 
    // Constructor
    Graph(int v)
    {
        V = v;
        adj = new LinkedList[v];
        for (int i=0; i<v; ++i)
            adj[i] = new LinkedList();
    }
 
    // Function to add an edge into the graph
    void addEdge(int v,int w)
    {
        adj[v].add(w);
    }
}
}
Unknown's avatar

605. Can Place Flowers

605. Can Place Flowers

class Solution {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        if(flowerbed.length == 1 && flowerbed[0] == 0) n--;
        for(int i = 0; i < flowerbed.length; i++){
            if(i ==0 && flowerbed[i] == 0 && i+1 <  flowerbed.length && flowerbed[i+1] == 0){
                flowerbed[i] = 1;
                n--;
            }else if( i == flowerbed.length -1 && 
                     flowerbed[i] == 0 && i-1 >= 0 &&
                     flowerbed[i-1] == 0){
            flowerbed[i] = 1;
                n--;
            }
            else if(flowerbed[i] == 0  &&
                    i-1 >= 0 &&
                    flowerbed[i-1] == 0  &&
                    i+1 <  flowerbed.length &&
                    flowerbed[i+1] == 0){
                flowerbed[i] = 1;
                n--;
            } 
        }
        if(n <= 0) return true;
        else return false;
    }
}
Unknown's avatar

Mini-Max Sum

https://www.hackerrank.com/challenges/mini-max-sum/problem

   public static void miniMaxSum(List<Integer> arr) {
    // Write your code here
         Collections.sort(arr);
         BigInteger sum = BigInteger.ZERO;
         for (int i = 0; i < arr.size(); i++){
              sum =sum.add(BigInteger.valueOf(arr.get(i)));
         }
         System.out.print(sum.subtract(BigInteger.valueOf(arr.get(arr.size()-1).intValue()))+" ");
         System.out.print(sum.subtract(BigInteger.valueOf(arr.get(0).intValue())));
      
    }