Johnnn Blog

Find nCr

Find nCr

The problem of finding the value of nCr (n choose r) arises in various mathematical and combinatorial scenarios. nCr represents the number of ways to choose r elements from a set of n elements,...

0 – 1 knapsack problem and solution

0 – 1 knapsack problem and solution

The 0/1 Knapsack problem is a classic optimization problem in computer science and mathematics. Given a set of items with their weights and values, and a knapsack with a maximum weight capacity, the goal...

Find K-th smallest element in an array

Find K-th smallest element in an array

In many programming scenarios, it becomes necessary to find the K-th smallest element in an array. This problem can be solved using various algorithms, each with its own time complexity. In this blog post,...