## Let’s define a “sevenish” number to be one which is either a power of 7, or the sum of unique powers of 7.

The first few sevenish numbers are 1, 7, 8, 49, and so on. Create an algorithm to find the nth sevenish number. JAVA JAVASCRIPT

Skip to content
# Author Archives: James

##
Let’s define a “sevenish” number to be one which is either a power of 7, or the sum of unique powers of 7.

##
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.

##
Implement a stack API using only a heap. A stack implements the following methods:

##
Given pre-order and in-order traversals of a binary tree, write a function to reconstruct the tree.

##
Given a string of parentheses, find the balanced string that can be produced from it using the minimum number of insertions and deletions

##
Given a binary tree, return the level of the tree with minimum sum.

##
Write a program to merge two binary trees. Each node in the new tree should hold a value equal to the sum of the values of the corresponding nodes of the input trees. If only one input tree has a node in a given position, the corresponding node in the new tree should match that input node.

##
Given a string which we can delete at most k, return whether you can make a palindrome.

##
Difference between BLoC and Cubit when using flutter_bloc package

##
Given a string, return the length of the longest palindromic subsequence in the string- Asked by Google

##
Implement a PrefixMapSum class with the following methods

##
Simple Example of using Draggable Widget in Flutter

##
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.

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

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

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

##
Write a program to compute the in-order traversal of a binary tree using O(1) space.

##
Flutter vs. React Native: Unraveling the Performance Battle

##
Different ways of making rounded corner images in flutter

##
Given an absolute pathname that may have . or .. as part of it, return the shortest standardized path

##
Riverpod in Flutter – Simplest Example Ever

##
Connect 4 is a game where opponents take turns dropping red or black discs into a 7 x 6 vertically suspended grid.

##
Roman numeral format to decimal.

##
Smallest sparse number greater than or equal to N.

##
10 Best Flutter Packages to use in your app

The first few sevenish numbers are 1, 7, 8, 49, and so on. Create an algorithm to find the nth sevenish number. JAVA JAVASCRIPT

For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4. Algorithm should run in O(n) complexity. JAVA JAVASCRIPT PYTHON

Recall that a heap has the following operations: To implement a stack using only a heap, you can use a max heap and maintain a counter to ensure that the order of elements is preserved. Here’s an example implementation in Python, Java, and JavaScript using the heapq module (Python), PriorityQueue (Java), and BinaryHeap (JavaScript): Python:… Read More »

For example, given the following preorder traversal: [a, b, d, e, c, f, g] And the following inorder traversal: [d, b, e, a, f, c, g] You should return the following tree: To reconstruct a binary tree from its pre-order and in-order traversals, you can use a recursive approach. The idea is to select the… Read More »

Given a string of parentheses, find the balanced string that can be produced from it using the minimum number of insertions and deletions. If there are multiple solutions, return any of them. For example, given “(()”, you could return “(())”. Given “))()(“, you could return “()()()()”. To find the balanced string with the minimum number… Read More »

Java: Javascript: Python:

Asked by SalesForce JavaScript: Java: Python: These programs define a TreeNode class and a function (mergeTrees in JavaScript, mergeTrees method in Java, and merge_trees function in Python) to merge two binary trees following the specified rules. You can adapt these examples based on your specific requirements.

Python: JavaScript: Java: These solutions check if a string can be converted into a palindrome by allowing at most k deletions. The is_palindrome function is used to check if a given substring is a palindrome. The Java solution includes a main method for example usage. Asked By: Google

Video Tutorial Lets understand this with an example we are going to create a basic counter example here using bloc and cubit. Here are the key differences between Bloc and Cubit in Flutter: Both Bloc and Cubit are part of the broader Flutter Bloc library and adhere to the principles of reactive programming. Your choice… Read More »

Given a string, return the length of the longest palindromic subsequence in the string. For example, given the following string: MAPTPTMTPA Return 7, since the longest palindromic subsequence in the string is APTMTPA. Recall that a subsequence of a string does not have to be contiguous! Your algorithm should run in O(n^2) time and space.… Read More »

insert(key: str, value: int): Set a given key’s value in the map. If the key already exists, overwrite the value. sum(prefix: str): Return the sum of all values of keys that begin with a given prefix. For example, you should be able to run the following code: mapsum.insert(“columnar”, 3) assert mapsum.sum(“col”) == 3 mapsum.insert(“column”, 2)… Read More »

In this example, we use the Draggable widget to create a draggable square-shaped container with a touch_app icon. Here’s a breakdown of the code: You can run this code in a Flutter project to see the draggable widget in action.

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 »

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 »

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 »

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 »

Python Java Javascript These implementations use the Morris Traversal algorithm to perform in-order traversal without using any additional space other than O(1). The algorithm establishes temporary links between nodes and their predecessors, allowing efficient traversal and processing of the tree nodes. Note: The code examples assume that the tree nodes have a val, left, and… Read More »

Introduction: When it comes to developing cross-platform mobile applications, Flutter and React Native have emerged as the two dominant frameworks. As developers seek to create high-performing apps, it’s crucial to understand the performance capabilities of each framework. In this article, we will delve into the performance aspects of Flutter and React Native, examining their strengths… Read More »

Example 1: ClipRRect dartCopy codeClipRRect( borderRadius: BorderRadius.circular(10.0), child: Image.asset(‘assets/images/image.jpg’), ) In this example, the ClipRRect widget is used to clip the child Image with rounded corners. The borderRadius property defines the radius of the corners. Example 2: BoxDecoration dartCopy codeContainer( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), image: DecorationImage( image: AssetImage(‘assets/images/image.jpg’), fit: BoxFit.cover, ), ), ) Here, a… Read More »

Given an absolute pathname that may have . or .. as part of it, return the shortest standardized path. For example, given “/usr/bin/../bin/./scripts/../”, return “/usr/bin/”. To obtain the shortest standardized path from an absolute pathname that may contain “.” or “..” as part of it, you can follow these steps: Here’s an example Python code… Read More »

In this example, we create a simple Flutter application that displays a counter and increments the count when a FloatingActionButton is pressed. The state management is handled by Riverpod. Here’s a breakdown of the code: When you run this code, you will see a simple app with an app bar, a counter in the center… Read More »

The game ends either when one player creates a line of four consecutive discs of their color (horizontally, vertically, or diagonally), or when there are no more spots left in the grid. Design and implement Connect 4. To design and implement Connect 4, we can follow these steps: Here’s an example implementation of Connect 4… Read More »

Given a number in Roman numeral format, convert it to decimal. The values of Roman numerals are as follows: { ‘M’: 1000, ‘D’: 500, ‘C’: 100, ‘L’: 50, ‘X’: 10, ‘V’: 5, ‘I’: 1 } In addition, note that the Roman numeral system uses subtractive notation for numbers such as IV and XL. For the… Read More »

We say a number is sparse if there are no adjacent ones in its binary representation. For example, 21 (10101) is sparse, but 22 (10110) is not. For a given input N, find the smallest sparse number greater than or equal to N. Do this in faster than O(N log N) time. Solution in Java… Read More »

Iconic One Theme | Powered by Wordpress