跟随,学习,进步

Acm

The Ultimate Computer Technology Blog | The Knowledgebase of Computing

https://helloacm.com/
转到作者网站

How to Re-Number the Files Sequentially on Windows using Batch Programming/Script?

You probably have a list of files e.g. camera pictures that you want to re-number sequentially. For example, the photos are named using dates-and-time string. However, this is not idea, as many of us... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Split a String in Balanced Strings?

Balanced strings are those who have equal quantity of ‘L’ and ‘R’ characters. Given a balanced string s split it in the maximum amount of balanced strings. Return the maximum... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Finding Out the Longest Arithmetic Subsequence of Given Difference using Dynamic Programming Algorithm

Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Count the Prime Number of Set Bits in Binary Representation?

Given two integers L and R, find the count of numbers in the range (inclusive) having a prime number of set bits in their binary representation. (Recall that the number of set bits an integer has is... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Create a Mock Echo Soap/REST API using SoapUI?

Modern Applications Development often requires testing APIs. If you don’t have backend API developed, you can create Mock API services using SoapUI. You probably can do the same thing using... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Partition Array into Disjoint Intervals?

Given an array A, partition it into two (contiguous) subarrays left and right so that: Every element in left is less than or equal to every element in right. left and right are non-empty. left has... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The Complex Number Multiplication Function

Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the definition. Example 1: Input: “1+1i”,... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Check if Array/List Contains Duplicate Numbers or Strings in Python using Set?

In Python, we can check if an array or list contains duplicate items using the following one-liner function. def contain_duplicates(list): return len(set(list)) != len(list) The idea is to convert... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Counting the Stepping Numbers between A Range using Depth/Breadth First Search Algorithm

A Stepping Number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a Stepping Number while 421 is not. Given two integers low and high,... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Intersection of Three Sorted Arrays using Three Pointers

Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays. Example 1: Input: arr1 = , arr2 = ,... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Reverse Substrings Between Each Pair of Parentheses using Stack?

You are given a string s that consists of lower case English letters and brackets. Reverse the strings in each pair of matching parentheses, starting from the innermost one. Your result should not... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Backpacking Problem Variation via Greedy Approach: How Many Apples Can You Put into the Basket?

You have some apples, where arr is the weight of the i-th apple. You also have a basket that can carry up to 5000 units of weight. Return the maximum number of apples you can put in the basket.... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Sliding Window to Get Equal Substrings Within MaxCost Budget

You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s – t| that is, the absolute difference... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Beginner’s Guide to Python’ Enumerate Function

You may see Python code like this: for i,v in enumerate(data): pass So, what does the enumerate() function do? The enumerate() in python takes a list as its first parameter, and optionally support... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Algorithms to Determine Unique Number of Occurrences

Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. Example 1: Input: arr = Output: true Explanation:... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The Next Permutation Algorithm in C++ (std::next_permutation)

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Binary Tree Zigzag Level Order Traversal Algorithms using DFS and BFS

Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Counting the Prime Arrangements

Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The Minimum Absolute Difference Algorithm of an Array

Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. Return a list of pairs in ascending order(with respect to pairs), each... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Implement the Depth First Search Algorithm in Graph using Simple C/C++

Given a graph represented by G(V, E) where V is the vertices and E represents the edges, we can do a Depth First Search Algorithm (DFS) on any node/vertex. The DFS will mark the current node visited... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]