▲ 10 r/codeforces+1 crossposts

OA question [HELP]

Got this question in my OA. I answered it, but I haven't heard back yet. I'm assuming my approach is wrong. Can anyone help me understand why?

Problem:

You are given a string S consisting only of decimal digits (0–9). The string represents a non-negative integer. You may delete any number of digits from S while preserving the relative order of the remaining digits. Your task is to construct the largest possible number such that every digit appearing in the resulting number occurs an even number of times.

Test case 1: 12121
Result: 2121

Test case 2: 121212
Result: 2121

My approach:

Deleting a digit with an odd frequency more than once is not optimal, as it would decrease the length and not maximize the answer. I used a monotonic stack based approach where I check if the top of the stack is smaller than the incoming digit and has an odd frequency. If yes, I delete that digit, as it will be replaced with a larger digit and help maximize the answer.

Once I'm done with the first pass, I do one more scan to check if I missed any odd-frequency digits that have a lexicographically larger digit in front of them, and delete their rightmost occurrence.

I was able to pass the sample test cases and submitted it on the Codility platform, but I was rejected. :(
Code:

def maximise_number(number):
    stack = []
    f = Counter(number)  # Frequency counting
    for num in number:
        while stack and stack[-1] < num and f[stack[-1]] % 2 == 1:
            stack.pop()
        stack.append(num)
    res = []
    while stack:
        if f[stack[-1]] % 2 == 0:
            f[stack[-1]] -= 1
            stack.pop()
        else:
            res.append(stack.pop())
    res.revese()
    return res
reddit.com
u/Puzzleheaded_Cow3298 — 3 days ago

Back in the summer last year, it took me 15 days to solve today's POTD. Today, I solved it in just 3 minutes. I guess hard work really does pay off, even for people like me who don't have much natural talent.

u/Puzzleheaded_Cow3298 — 4 days ago
▲ 741 r/hyderabad

Is Telugu just a second class language in Hyderabad now?

I today went to one of the famous malls in hyd with my cousins, just to have some fun.

We shopped for some clothes at a clothing brand outlet there. The billing staff were North Indians and spoke only Hindi (maybe even English, but Idk). In front of us in the billing line were two middle aged women who spoke only Telugu. Since various items had different discount slabs and billing amounts, although they could understand the numbers the cashier was saying, they still couldn't understand most of what the cashier was trying to explain.

So my cousin asked them if he could help translate so it would help them and also speed up the billing, as we were behind them in the line. After the billing was done, the cashier told the lady, "You're in Hyderabad, learn Hindi as well" with a smirk on her face.

My cousin instantly lost it. In anger, he shouted at the billing staff and said, "You guys come here to make a living, don't rub your goddamn language on us." The cashier immediately started apologizing after seeing how angry my cousin got. The aunties in front of us could make out what was happening.

Another cousin of mine called the store manager, who was apparently busy asking (begging) customers to leave 5 star ratings on google maps. He came over, and he's a North Indian too. He understands Telugu and probably even speaks a bit. Once my cousin told him what had happened, his reply to us was, "Stop being troublemakers. It's not a big deal; Hindi is a national language" The fuck? Since when did wanting to speak our own language and not knowing other languages become "being a troublemaker"?

Some people gathered to see what was going on, and the store manager apologised for the words he had said earlier. When did we become like this?

reddit.com
u/Puzzleheaded_Cow3298 — 7 days ago
▲ 24 r/telugu

How do you type in Telugu?

Telugu is my mother tongue. I can read and write it fluently, but I have a hard time typing in it.

I've tried google translate and a few other websites, but none of them feel accurate enough.

Meeru ela type chestaru? What tool do you use

reddit.com
u/Puzzleheaded_Cow3298 — 8 days ago

HELP ME, PLEASE !

I'm 25M. Ma family ki oka steel factory undhi Spain lo. I'm a multi-billionaire and tbh, na watch ammesthe ee sub lo andharu settle ayipovachu.

Ma company lo major stakeholders ma family ne. Ippudu vere shareholders maku ishtam leni decision tiskundham anukuntunnaru. Dhanni memu oppose cheyyalekapothunnam endhukante ma family shares lo 30% ma atha peru meedha unnayi. Thanu emo ma thathaki ishtam leni pelli cheskoni Hyderabad ellipoyindhi.

Inka na company ela aina save cheyyali ani, ma athani ela aina oppinchali ani Hyderabad ocha. Flight digagane ma mama kanipinchadu. Intiki drive cheskuntu eltunnadu, nenu kuda creep la follow ayipoya.

Madhyalo mama ki heart attack ochindhi, hospital lo join chesa. Inka aa gratefulness ki valla intlo driver laga job icharu. Nenu kuda na plan lo progress kanipistundi ani join ayipoya. Intloki enter avvagane, I saw my pedha maradhal (atha ki iddharu kuthurlu). She's hella pretty. Now I got a big crush on her. Ameni ela aina pelli cheskoni ma family ni kalipedham anukuntunna. Em antaru? Lechipoyi pelli cheskunte, ela untadhi?

FYI, I'm 6'0", built like a bullet (ante andharu aaru adugula bullet antaru, so).

reddit.com
u/Puzzleheaded_Cow3298 — 10 days ago

Letting go of my Activa Scooty 3G

Location: Nizampet

Price: Free

Reason : My dad got into an accident while riding it, and my mom believes we shouldn’t keep the scooty anymore for religious reasons (idk exactly).

Condition: Mostly good, with moderate scratches and a big dent near the front-left headlight. You may have to spend a maximum of 10k to make it look and work like brand new.

Bought: 2016–2017

Willing to give it away if someone is okay with paying the ownership transfer costs and other related charges.

Photos: definitely can’t share them here. I’ll get doxxed. If you’re interested, just drop me a DM. I’ll share them there.

reddit.com
u/Puzzleheaded_Cow3298 — 16 days ago