'Coding has over 700 languages', '67% of programming jobs aren’t in the technology industry', 'Coding is behind almost everything that is powered by electricity'
Coding Ninjas Studio contest
Beginner Contest 54
+2540 other showed interest
Contest ended
( IST)
Leaderboard
Discussion
Contest details
Rewards
Rules & FAQs
Contest leaderboard rules
EXP-Based Ranking:
Your leaderboard rank is influenced by your total EXP, which you accumulate by solving each question. The more EXP you gather, the higher your rank ascends.
Tie-Breaker Rule:
Should there be a tie in total EXP among participants, precedence is granted to the one who reached their total EXP first. This ensures a fair and competitive ranking.
Time Calculation:
The duration for accumulating EXP is measured from the contest's official start time. This ensures uniformity, as it does not depend on each participant’s start time.
Discussion
Go to discussion page
profile
Codestudio
Beginner Contest 54
Contests and hackathons
views
404
views
chat
2
replies
upvote
0
upvotes

Hey Ninjas!

This is a post to ask doubts and share your logic for solving questions from Beginner Contest 54! 😄
You can also view the rankings for the contest here (link).

If you face any issues during the contest, do let us know by replying below. ✌️

How was your experience in the contest or got any feedback? Let us know here (link)

upvote
0 Upvoted
Published on 21 Feb, 2024
Replies (2)
profile
Bharat Makkar
22 Feb, 2024

For the 2nd question (Get Greedy), I came up with the following recursive solution:-

 

import java.util.ArrayList;

public class Solution {

    static int maximiseScore(int n, int k, ArrayList<Integer> a) {

        

        int front = 0;

        int back = a.size()-1;

 

        int sum = 0;

 

        for(int i=0;i<a.size();i++)

        {

            sum = sum + a.get(i);

        }

        

        int score = 0;

 

        return maximiseScoreHelper(a,front,back,sum,score,k);

    }

 

    static int maximiseScoreHelper(ArrayList<Integer> a,int f,int b,int sum,int score,int k)

    {

        if(sum<k || f>a.size()-1 || b<0 ||f>b)

        {

            return score;

        }

 

            int includeFront = maximiseScoreHelper(a, f+1, b, sum - a.get(f), score+a.get(f), k);

            int includeBack = maximiseScoreHelper(a, f, b-1, sum - a.get(b), score+a.get(b), k);

 

            int maxScore = Math.max(includeBack,includeFront);            

 

            return maxScore;

    }

}

 

My code fails for the test case:

n = 8, k = 56 , arraylist - 8, 56, 38, 5, 30, 14, 40, 2, 47, 43 

 

I am still unable to figure what's wrong in my code? Also, will appreciate any suggestion as to how to dry-run code without making a recursion tree.

chat
0
replies
upvote
upvotes
reply
Reply
profile
Xianming Zhong
21 Feb, 2024

The third problem is wrong. And I have reported to the admin. Sad contest.

chat
0
replies
upvote
upvotes
reply
Reply
Contest details

Who Can Participate:

Coding Ninjas Studio is organizing this coding contest for beginner coders and is open to programmers from all across the globe. Everyone from freshers to professionals can participate.


About The Contest:

Coding Ninjas Studio contest is our weekly coding competition. In this contest, the coders compete while also improving their overall algorithmic knowledge. The coding contest helps students and professionals tackle a problem by reading the concepts one doesn’t know, and also gain practical experience by coding the solution to the problem, thus improving their skills significantly. This coding competition packs the excitement of programming with the fun of learning into one compelling challenge. Don't forget to try out a sample problem if you are new to Coding Ninjas Studio.

 

Duration Of The Programming Contest: 1.5 hours(90 mins)

Sample problem for you
Rewards

Rewards - Coding Ninjas Studio EXP

  • 1st - 1000
  • 2nd - 750
  • 3rd - 500
  • 4th-10th - 250
  • 11th-50th - 100
  • First Contest - 200
  • Participation - 100
Rules
  • You can submit solutions as many times as you'd like, there are no penalties for incorrect submissions. Only your best correct submission will be considered.
  • Those who achieve the score first will be placed higher in the ranklist in case of a tie.
  • Discussing Coding Ninjas Studio contest problems or any aspect of the problem, on any other platform on the web, on identification, could lead to disabling of respective account and banning from the community.
  • Please do not discuss strategy, suggestions, or tips in the comments during a live contest. Posting questions clarifying the problem statement is ok. If you are unsure, feel free email us at parikh@codingninjas.com
  • The problems will be partially graded. You will get score for passing certain test cases.
  • Facing any kind of issues, email us at support@codingninjas.com
For any issues and inquiries mail us at
support@codingninjas.com
FAQs
Which browser should i prefer to use to participate in contest?
What kind of questions can i expect in Coding Ninjas Studio contests?
Can I leave the test in between and continue later?
What if i encounter technical issues during the test?
What is the meaning of EXP?
Can we participate in contests from mobile?
Will I receive the results of the contest? If yes, when?
Will I get the allotted time to attempt the contest if I start the contest just few mins before the event End Time?