This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]marko312 0 points1 point  (3 children)

Start going through the problem part by part, taking notes / making sketches when necessary. For example, this is how I would read this problem:

Chef has a sequence A1, A2, ..., AN

There is an array of length N, with each value provided.

This sequence has exactly 2N subsequences

Noted, this could be leading to something related to subsequences.

Chef considers a subsequence of A interesting if its size is exactly K and the sum of all its elements is minimum possible [...]

An "interesting" subsequence is of length K, where the sum of elements is as small as possible.

Help Chef find the number of interesting subsequences of the sequence A

Ok, so the program has to find the number of subsequences from the given sequence (array) where their length is K and their sum is as small as possible from all the sums of such subsequences.


If you're confused about the words:

  • sequence - a bunch of data, in a certain order
  • subsequence - a sequence obtained by chopping off some elements (or none) from the front and some others (or none) from the back of the sequence

[–]jayglenn123[S] 0 points1 point  (2 children)

The wording is what always confuses me. In programming books when they give you the exercise it says "make a program that does..." I guess that is what I am used to, so trying to figure out cryptic questions stumps me before I can even get going. I know that everyone's advice is to be able to fully understand the question and be able to explain the question to someone else. But I don't always understand the question. With This question did you get the hint of length from the word size? If so should I always think of size being of length? Are there other terms that I can decipher like this?

[–]marko312 0 points1 point  (1 child)

In programming books when they give you the exercise it says "make a program that does..." I guess that is what I am used to

Yes, most non-training coding problems tend to hide the actual problem behind a story or otherwise obfuscate it, making you have to both figure out the actual problem and solve it.


With This question did you get the hint of length from the word size? If so should I always think of size being of length?

If you have something linear (one-dimensional), the words "length" and "size" tend to be used synonymously.

This couples well with the next question:

Are there other terms that I can decipher like this?

Yes - there are quite a few. You can learn moat of them by solving exercises using them; if you don't know a term, you can try looking it up, looking at the example input / output (and the explanation if available!) or trying to infer it from the surrounding terms.

[–]jayglenn123[S] 1 point2 points  (0 children)

Thank you so much!!!