Skip to content
Advertisement

Tag: algorithm

First occurrence of 1 in unsorted binary array

I am solving a problem to find the first 1 in an unsorted array of 1s and 0s. If any 1 is found program should return the index otherwise return -1. I would like to have divide and conquer solution for this problem, but I am struggling with the base case. So what should my base case be – to

Explain the logic of ‘Count of N-digit numbers with absolute difference of adjacent digits not exceeding K’ in Detail

Can someone please help me understand the logic of following Dynamic Programmming question Found this one at geeksforgeeks.com. I am unable to understand even after going through the answer provided. Question: Count of N-digit numbers with absolute difference of adjacent digits not exceeding K | Set 2 Given two integers N and K, the task is to find the count

Advertisement