CodeChef Contest 184 – All Questions Solved FREE πŸ’»πŸ”₯ | 30 April 2025 | 3⭐ Rated

 

CodeChef Contest 184 – All Questions Solved FREE πŸ’»πŸ”₯ | 30 April 2025 | 3⭐ Rated 




Myntra is Hiring Software Development Intern - Batch of 2026 - Open Campus- Apply Now



πŸ‘‡Scroll down to get all solutions!πŸ‘‡



Are you ready for another exciting CodeChef-rated contest? Starters 184 is here to test your coding skills and problem-solving abilities! Whether you're a beginner or an intermediate coder (rated up to 5 stars), this is your chance to compete, improve, and rank up.


πŸ—“οΈ Contest Date: April 30, 2025
⏰ Time: 08:00 PM – 10:00 PM IST | πŸ•’ Duration: 2 Hours
πŸ† Contest Name: CodeChef Starters 184

🚨 Note: The Code of Conduct has been updated β€” make sure to follow the latest rules!!


πŸ”₯ Get All Contest Solutions!

Want access to all solutions from this contest? Just follow these simple steps:

βœ… Step 1: Subscribe to our YouTube channel
πŸ“Έ Step 2: Take a screenshot of your subscription
πŸ’¬ Step 3: Send the screenshot along with your Telegram name (as it appears in Telegram)
πŸ”‘ Step 4: Get admin access to our Official Telegram Channel and receive all the solutions!

πŸ“’ Join now and never miss any updates!
πŸ‘‰ https://t.me/+0dnF7vnXJ8lkOGFl

πŸ’‘ All solutions will be uploaded, so make sure to subscribe and join our Telegram channel!

πŸš€ Don’t miss this opportunity to learn, compete, and grow as a coder! Let’s crack Starters 184 together! πŸ”₯πŸ’»



πŸ‘‡Scroll down to get all solutions!πŸ‘‡



#Promotion

πŸš€ Grow Your Instagram Fast – Get Real Followers, Likes & Views Starting at Just β‚Ή5!

😎 DEMO FOR ALL SERVICES AVAILABLE – START NOW


Place Your First Order & Watch the Magic Begin in Just 5–10 Minutes!
βœ” Instant Delivery | βœ” 100% Money-Back Guarantee

⚑ DEMO SERVICES
1️⃣ 500 Followers – Just β‚Ή80 πŸ€‘
2️⃣ 500 Likes – Only β‚Ή5 😊
3️⃣ 1K Reels Views – Just β‚Ή5 😍


πŸ¦‹ CHEAPEST GUARANTEED INSTAGRAM FOLLOWERS


1K Followers – β‚Ή150
2K Followers – β‚Ή270
3K Followers – β‚Ή400
5K + 1K FREE – 600
10K + 1K FREE – β‚Ή1200


βœ… No Drops | βœ… Real Followers | βœ… Trusted Quality


❀ INSTAGRAM GUARANTEED LIKES
1K Likes – β‚Ή10
5K Likes – β‚Ή45
10K Likes – β‚Ή90
20K Likes – β‚Ή180
30K Likes – β‚Ή250
40K Likes – β‚Ή300
50K Likes – β‚Ή400

πŸŽ₯ INSTAGRAM REELS VIEWS
1K Views – β‚Ή5
5K Views – β‚Ή20
10K Views – β‚Ή30
20K Views – β‚Ή35
30K Views – β‚Ή50
40K Views – β‚Ή80
50K Views – β‚Ή100
500K Views – β‚Ή250
1M Views – β‚Ή400

πŸ“² CONTACT NOW TO PLACE YOUR 1ST ORDER

Order Now : Contact On WhatsApp


Service Proof : Instagram Id

✨ Be Viral. Be Famous. Be YOU – With the Power of Social Growth!


Please Subscribe Our YouTube Channel

NOTE :- Don’t copy the full code β€” use the logic.
We're not responsible for plagiarism issues.
Thank you!





Q1 Solutions -

n = int(input())
rem = n % 3
if rem == 0:
    print(n)
elif rem == 1:
    print(n - 1)
else:
    print(n + 1)

Q2 Solutions -

test_cases = int(input())
for _ in range(test_cases):
    length = int(input())
    if length == 1:
        print(-1)
    elif length % 2 == 0:
        result = [1, -1] * (length // 2)
        print(*result)
    else:
        result = [1, 2, -3]
        for _ in range((length - 3) // 2):
            result += [1, -1]
        print(*result)




If we've helped you, please support us with a donation. β€οΈπŸ™


Q4 Solutions -

import sys

def mod_pow(base, exp, mod):
    result = 1
    base %= mod
    while exp:
        if exp & 1:
            result = (result * base) % mod
        base = (base * base) % mod
        exp >>= 1
    return result

def solve():
    n = int(sys.stdin.readline())
    arr = list(map(int, sys.stdin.readline().split()))
    MOD = 998244353

    # Count occurrences of each value in [0..n-1]
    counts = [0]*n
    for x in arr:
        if 0 <= x < n:
            counts[x] += 1
        else:
            print(0)
            return

    # Check the β€œmiddle” element if n is odd
    if n & 1:
        mid = n//2
        if counts[mid] != 1:
            print(0)
            return

    # Check pairing counts[k] + counts[n-1-k] == 2
    for k in range(n//2):
        if counts[k] + counts[n-1-k] != 2:
            print(0)
            return

    # All good β†’ output 2^(n/2) mod
    print(mod_pow(2, n//2, MOD))

# Driver
t = int(sys.stdin.readline())
for _ in range(t):
    solve()


Q5 Solutions

import sys
input = sys.stdin.readline

def process_ops(n, ops):
    # state[i] = whether value i has been β€œused”
    used = [False] * (n + 5)
    used[0] = True

    next_free = 1      # next integer not yet in state
    current_size = 1   # how many values are in state
    inv_count = 0      # inversion-like counter
    cross_count = 0    # cross-term accumulator

    result = []
    for op in ops:
        if op == 1:
            # Add a single new element
            inv_count += current_size
            cross_count += current_size
            used[next_free] = True
            current_size += 1
            # Advance next_free to the next unused integer
            while used[next_free]:
                next_free += 1
        else:
            # Double the structure
            inv_count = inv_count * 2 + cross_count
            cross_count *= 4
            current_size *= 2
        result.append(inv_count)
    return result

def main():
    t = int(input())
    for _ in range(t):
        m = int(input())
        ops = list(map(int, input().split()))
        print(*process_ops(m, ops))

if __name__ == "__main__":
    main()




Q6 Solutions- (if You want Solution , then Subscribe)

import sys
input = sys.stdin.readline

MOD = 998244353

class SMEXCalculator:
    def __init__(self, A):
        self.A = A
        self.N = len(A)
        self.MOD = MOD

    def modinv(self, x):
        # Fermat’s little theorem
        return pow(x, self.MOD - 2, self.MOD)

    def build_counts(self):
        cnt = [0] * (self.N + 2)
        for v in self.A:
            cnt[v] += 1
        return cnt

    def build_prefixes(self, cnt):
        Zcnt = [0] * (self.N + 3)
        P_all = [1] * (self.N + 3)
        P_nz  = [1] * (self.N + 3)
        S_inv = [0] * (self.N + 3)

        for k in range(1, self.N + 2):
            zero_here = 1 if cnt[k-1] == 0 else 0
            Zcnt[k] = Zcnt[k-1] + zero_here

            Q = (pow(2, cnt[k-1], self.MOD) - 1) % self.MOD
            P_all[k] = P_all[k-1] * Q % self.MOD

            if cnt[k-1] > 0:
                P_nz[k]  = P_nz[k-1] * Q % self.MOD
                S_inv[k] = (S_inv[k-1] + self.modinv(Q)) % self.MOD
            else:
                P_nz[k]  = P_nz[k-1]
                S_inv[k] = S_inv[k-1]

        return Zcnt, P_all, P_nz, S_inv

    def build_suffixes(self, cnt):
        p2 = [pow(2, c, self.MOD) for c in cnt]
        suf = [1] * (self.N + 4)
        for v in range(self.N + 1, -1, -1):
            suf[v] = p2[v] * suf[v+1] % self.MOD
        return suf

    def compute(self):
        cnt = self.build_counts()
        Zcnt, P_all, P_nz, S_inv = self.build_prefixes(cnt)
        suf = self.build_suffixes(cnt)

        ans = 0
        for k in range(1, self.N + 2):
            z = Zcnt[k]
            if z >= 2:
                sumR = 0
            elif z == 1:
                sumR = P_nz[k]
            else:
                sumR = P_all[k] * S_inv[k] % self.MOD

            Ck = sumR * suf[k+1] % self.MOD
            ans = (ans + k * Ck) % self.MOD

        # subtract empty-subsequence contribution
        return (ans - 1) % self.MOD

def solve_one(A):
    return SMEXCalculator(A).compute()

def main():
    T = int(input())
    out = []
    for _ in range(T):
        n = int(input())
        A = list(map(int, input().split()))
        out.append(str(solve_one(A)))
    print("\n".join(out))

if __name__ == "__main__":
    main()


Q7 Solving Now........

T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    # Check if boundaries match
    if A[0] != B[0] or A[N-1] != B[N-1]:
        print("No")
        continue
    
    # Check blocks of 1s in B
    block_ok = True
    i = 0
    while i < N and block_ok:
        if B[i] == 0:
            i += 1
            continue
        l = i
        while i < N and B[i] == 1:
            i += 1
        r = i - 1
        # Check if there is at least one 1 in A[l:r+1]
        has_one = any(A[k] == 1 for k in range(l, r+1))
        if not has_one:
            block_ok = False
    
    if not block_ok:
        print("No")
        continue
    
    # Check positions where B[i] = 0 and A[i] = 1
    set_ok = True
    for j in range(1, N-1):
        if B[j] == 0 and A[j] == 1:
            if A[j-1] == 1 or A[j+1] == 1:
                set_ok = False
                break
    
    if set_ok:
        print("Yes")
    else:
        print("No")






Comments

Post a Comment

Popular posts from this blog

Get All Coding Solutions

Codeforces Contest Round 1025 (Div.2) | All Questions Solutions – FREE! | 17 May 2025