Tag Archives: programming

Problem: You are given N identical eggs and access to a building with k floors. Your task is to find the lowest floor that will cause an egg to break, if dropped from that floor.

By | July 2, 2023

You are given N identical eggs and access to a building with k floors. Your task is to find the lowest floor that will cause an egg to break, if dropped from that floor. Once an egg breaks, it cannot be dropped again. If an egg breaks when dropped from the xth floor, you can… Read More »

Create an algorithm that arranges them in order to form the largest possible integer

By | July 2, 2023

Given a list of numbers, create an algorithm that arranges them in order to form the largest possible integer. For example, given [10, 7, 76, 415], you should return 77641510. Javascript function largestNumber(nums) {  nums.sort((a, b) => {    const order1 = String(a) + String(b);    const order2 = String(b) + String(a);    return order2.localeCompare(order1); … Read More »

Problem: There are N prisoners standing in a circle, waiting to be executed…

By | June 27, 2023

There are N prisoners standing in a circle, waiting to be executed. The executions are carried out starting with the kth person, and removing every successive kth person going clockwise until there is no one left. Given N and k, write an algorithm to determine where a prisoner should stand in order to be the… Read More »

Given a sorted array, find the smallest positive integer that is not the sum of a subset of the array.

By | June 27, 2023

Java public class SmallestPositiveInteger {    public static int findSmallestPositiveInteger(int[] nums) {        int smallest = 1;        for (int num : nums) {            if (num <= smallest) {                smallest += num;            } else… Read More »

Custom Theme using Theme Extensions

By | December 16, 2022

Theme extensions were introduced in Flutter 3. But what are Theme Extensions? As the name says, it helps to extend the inbuilt themes with our own extensions. Let’s jump into an example So when you create a flutter app, your basic root widget will look like this return MaterialApp( title: ‘Flutter Theme Extensions’, theme: ThemeData(… Read More »