๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
public static int countUniqueCharacterSets(int N, String A) {
        Set<Set<Character>> uniqueSets = new HashSet<>();
       
        for (int i = 0; i < N; i++) {
            Set<Character> currentSet = new HashSet<>();
            for (int j = i; j < N; j++) {
                currentSet.add(A.charAt(j));
                uniqueSets.add(new HashSet<>(currentSet)); 
            }
        }
       
        return uniqueSets.size();
    }

Character Set Count โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public static int solution(int N, int K, int[] cost, int[] sell) {
        int maxProfit = 0;
        List<Item> items = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            items.add(new Item(cost[i], sell[i]));
        }

        Collections.sort(items, Comparator.comparingInt(Item::getSellPrice));

        int low = 0, high = items.size() - 1;

        while (low <= high) {
            int mid = low + (high - low) / 2;
            int buyingPrice = items.get(mid).getBuyPrice();

            if (K >= buyingPrice) {
                maxProfit = Math.max(maxProfit, items.get(mid).getSellPrice() - buyingPrice);
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }

        return maxProfit;
    }
}

class Item {
    private int buyPrice;
    private int sellPrice;

    public Item(int buyPrice, int sellPrice) {
        this.buyPrice = buyPrice;
        this.sellPrice = sellPrice;
    }

    public int getBuyPrice() {
        return buyPrice;
    }

    public int getSellPrice() {
        return sellPrice;
    }
}

Profits โœ…
๐Ÿ‘1