String Compression Problem in O(n) time complexity | Java interview question

Sdílet
Vložit
  • čas přidán 7. 05. 2024
  • Welcome to Code With Roy !!
    Here, we dive deep into the world of IT, covering a wide range of topics including Core Java concepts, Spring Boot, Microservices, Java interview experiences for both freshers and experienced professionals, and insights into the dynamic IT life.
    Whether you're just starting your IT journey or looking to enhance your skills and knowledge, you'll find valuable content tailored to your needs. Our main goal is to provide comprehensive resources, tutorials, tips, and real-world experiences to help you succeed in the ever-evolving technology field.
    🎯 Ready to ace your interviews and level up your career? Book a personalized 1:1 mentorship session with me!
    In this exclusive mentorship program, you'll get tailored guidance and expert insights to help you excel in your interviews and achieve your career goals. Whether you're preparing for a job interview, seeking career advice, or aiming for professional growth, I'm here to support you every step of the way.
    topmate.io/debjeetroy
    Connect with us on LinkedIn for professional networking and updates: [LinkedIn Digital Debjeet]( / digitaldebjeet )
    Join our Telegram channel for discussions, Q&A sessions, and exclusive content: [Telegram Channel](t.me/+sBtqK4uYxBswNWZl)
    Don't forget to hit the subscribe button and turn on notifications so you never miss out on our latest uploads. Thank you for joining us on this exciting journey through the IT world!

Komentáře • 4

  • @ketulpatel1161
    @ketulpatel1161 Před 23 dny

    You explained very well... Pasting more simplified code:
    public static void main(String[] args) {
    String str = "w4a3d1e1x6";
    StringBuilder strBuilder = new StringBuilder();
    for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    if (Character.isDigit(c)) {
    int j = (c - '0');
    while (j != 0) {
    strBuilder.append(str.charAt(i - 1));
    j--;
    }
    }
    }
    System.out.println("Output String: " + strBuilder);
    }

  • @dailycodingproblem
    @dailycodingproblem Před měsícem

    What if the input is w4s6w8a9

    • @codeWithDebjeet
      @codeWithDebjeet  Před měsícem

      @dailycodingproblem it considers each character are unique in string otherwise we can write w4w7w9. Ye will it identify difference. I hope you got it

    • @dailycodingproblem
      @dailycodingproblem Před měsícem

      @codeWithDebjeet can you give the link of the question ,also why we are not considering numbers more than 1 digit ex w12s8