idfc logo
Idfc· SDE III

IDFC OA SDE3

Posted
1 May 2026
226 reads

Summary

I was asked two questions on HackerRank. One was easy and I'm sharing the second harder question which involved manipulating special binary strings.

How it went

Got asked 2 questions on hackerrank, one was easy, sharing the second question

Special binary strings are binary strings with the following two properties:

The number of 0's is equal to the number of 1's.
Every prefix of the binary string has at least as many 1's as 0's.

You are given a special binary string s.

A move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.

Return the lexicographically largest resulting string possible after applying the mentioned operations on the string.

https://leetcode.com/problems/special-binary-string/description/

Questions asked (1)

  1. 01

    Special Binary String

    Data Structures & Algorithms · Hard

    Special binary strings are binary strings with the following two properties:

    • The number of 0's is equal to the number of 1's.
    • Every prefix of the binary string has at least as many 1's as 0's.

    You are given a special binary string s.

    A move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.

    Return the lexicographically largest resulting string possible after applying the mentioned operations on the string.

    Open the problem

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Idfc recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!