Lily's Homework

Sort by

recency

|

21 Discussions

|

  • + 0 comments

    Reviving Teammates Once a shrine has been placed, gamers will need to technique the shrine and location the glowing coronary heart in their deceased teammate on pinnacle of it. As soon as this is carried out, gamers will need to start a lengthy ritual of prayer at the shrine. Players must only start this ritual when they are quite secure to achieve this, because the ritual to revive fallen teammates takes quite a long term to complete, leaving the participant and their crew at risk of ambush with the aid of monsters or different gamers.

    Once gamers finish channeling the ritual, the heart could be ate up, reviving the teammate who the coronary heart belongs to. Players can then supply their teammate their gear back that was looted formerly, as the revived group member will haven't any gadget in any respect whilst they come again, and they could preserve to try to acquire greater spoils in the course of the dungeon.

  • + 0 comments

    Pool compliance refers to adhering to local regulations and safety standards concerning the construction, maintenance, and operation of swimming pools.

  • + 0 comments

    Pool compliance refers to adhering to the regulations and safety standards set by local authorities regarding the construction, maintenance, and operation of swimming pools.

  • + 1 comment

    Few cases are still failing. Not sure why

    public static int lilysHomework(List<Integer> arr) {
            
            List<Integer> sor = new ArrayList<>(arr);
            Collections.sort(sor);
            int asc = sove(sor, new ArrayList<>(arr));
            
            Collections.reverse(sor);
            int dec = sove(sor, new ArrayList<>(arr));
            return Math.min(asc, dec);
        }
        
        public static int sove(List<Integer> arr, List<Integer> org) {
            Map<Integer, Integer> iMap = new HashMap<>();
            for (int i = 0; i < org.size(); i++) {
                iMap.put(org.get(i), i);
            }
            int count = 0;
            for (int i = org.size() - 1; i >= 0; i--) {
                if(org.get(i) != arr.get(i)) {
                    int in = iMap.get(arr.get(i));
                    org.set(in, org.get(i));
                    org.set(i, arr.get(i));
                    iMap.put(org.get(i), in);
                    count++;
                }
            }
            return count;
        }
    
  • + 0 comments

    Python

    def countSwaps(arr, r):
        arr = arr.copy()
        target = sorted(arr, reverse = r)
        inds = {v:i for i,v in enumerate(target)}
        i = 0
        count = 0
        while i < len(arr) and arr != target:
            while arr[i] != target[i]:
                ind = inds[arr[i]]
                arr[i], arr[ind] = arr[ind], arr[i]
                count += 1
            i += 1
        return count
    
    def lilysHomework(arr):
        return min(countSwaps(arr, False), countSwaps(arr, True))