dkyu021's blog

By dkyu021, history, 7 weeks ago, In English

Hello everyone, I hope you all are doing well and are healthy & fit.

I just wanted to ask why am I getting TLE with this submission My Submission, whereas all other codes with same logic and I guess same code structure is accepted, For example

Question Link

I don't know what am I missing in my submission?

Your help is very much appreciated and Thank you in advance.


  • Yes changing i<=sqrt(n) to i*i<=n is worth changing. But after that also I was getting a TLE!
  • After changing Long Long to int gave me AC.

I get the reason why changing sqrt(n) can decrease time, but what's with changing Long Long to int, how is it contributing to reduce time??

Read more »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By dkyu021, history, 3 months ago, In English

Although I'm too a beginner but I try to learn new things everyday, so here are the questions on DS which beginners like me find hard but are too easy if learned the DS nicely.


Index Problem Prerequisite
1 Maximum circular subarray sum Kadane's Algorithm
2 Find subarray with given sum Hashing
3 Equilibrium index of an array None
4 Maximum Sum Increasing Subsequence Simple DP
5 K-Concatenation Kadane's Algorithm
6 Convert array into Zig-Zag fashion None
7 Find a pair with the given difference Hashing
8 Chocolate Distribution Problem None
9 Minimum Number of Platforms Required for a Railway/Bus Station None
10 Trapping Rain Water None
11 Stock Buy Sell to Maximize Profit None
12 Rotate by 90 degree None
13 Find k pairs with smallest sums in two arrays None
14 Search in a Rotated Array None
15 Given a sorted and rotated array, find if there is a pair with a given sum None
16 Max sum in the configuration None
17 Array of alternate +ve and -ve no.s Caution: When submitting the solution WA as they have not given clarity on how the array has to be change although the code changes the array as specified in the question
18 Three way partitioning Dutch National Flag Quick Sort
19 Sort an array of 0s, 1s and 2s Dutch National Flag Quick Sort
20 Maximum length Bitonic Subarray In O(n) space
21 Maximum length Bitonic Subarray In O(1) space
22 Count Square Submatrices with All Ones None


Index Problem Prerequisite
1 Largest Rectangle in Histogram None
2 Stock Span Problem None
3 Reverse a Stack without using extra space Recursion
4 Delete middle element of stack Recursion
5 Sort a Stack Recursion
6 Sed Max None
7 Move Brackets None
8 Power Set Recursion

Segment Trees

Index Problem Prerequisite
1 Range Minimum Query None
2 Help Ashu None

Greedy Algos

Index Problem Prerequisite
1 Activity Selection Caution: Wrong test case on Geeks for Geeks
2 Egyptian Factors Mathematics
3 Job Sequencing Problem None
4 Water Connection Problem None
5 Police Catch Thieves None


Index Problem Prerequisite
1 Connected Components in a Graph DFS on undirected graph
2 Bishu and his Girlfriend DFS on undirected graph
3 Is it a tree Graph knowledge
4 A Bug’s Life Bipartite graphs
5 Fire Escape Routes Connected Components
6 Counting Rooms DFS on 2D grid
7 Longest path in a tree Diameter of tree
8 A Walk to Remember Kosaraju's algo
9 Maximum Size DFS on 2D grid
10 Detect cycle in an undirected graph DFS
11 Detect cycle in a directed graph DFS
12 Tree House DFS
13 Rat in maze Problem 1 DFS on 2D grid and Backtracking
14 Flood Fill DFS on 2D grid
15 Number of Operations to Make Network Connected Connected Components


Index Problem Prerequisite
1 Monk and the Islands BFS on undirected graph
2 Prime Path Sieve of Erosthenes and BFS
3 Feasible relations BFS
4 Social Networking Graph BFS
5 Jungle Run BFS on 2D grid
6 Chess knight move BFS on 2D grid
7 Bitmap BFS on 2D grid
8 Lucius Dungeon BFS on 2D grid
9 The Cats and the Mouse BFS on 2D grid
10 Word Ladder BFS
11 Jump Game VII BFS

Disjoint Set

Index Problem Prerequisite
1 Teacher's Dilemma None

Bit Manipulation

Index Problem Prerequisite
1 Number of 1 Bits None
2 Non Repeating Numbers None
3 Bit Difference None
4 Power Set None
5 Count Total Set Bits None
6 And Then There Were K None

I invite you all to add questions here

Read more »

  • Vote: I like it
  • +17
  • Vote: I do not like it

By dkyu021, history, 3 months ago, In English

Hello Codeforces,

I have one doubt, are these statements not same ?

Statement 1: int up = x/y;

Statement 2: int up = floor((float)x/(float)y);

I might be doing a very naive or silly mistake but I'm not able to see the difference.

Question is like:

Link to problem (Total Pairs): Question Link


My solutions to problem:

Wrong Solution
Accepted Solution

Thanking You all in advance!!!

Read more »

  • Vote: I like it
  • +4
  • Vote: I do not like it