ZS Associates interview question

Use of Window Function and real life application