Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use java to solve the next permutation problem

2025-04-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you how to use java to solve the next arrangement problem, the content is easy to understand, clear, hope to help you solve doubts, the following let the editor to take you to study and learn "how to use java to solve the next arrangement problem" this article.

To implement the function to get the next arrangement, the algorithm needs to rearrange the given sequence of numbers into the next larger arrangement in the lexicographic order.

If there is no next larger arrangement, the numbers are rearranged into the smallest arrangement (that is, ascending order).

It must be modified in place, and only extra constant space is allowed.

Here are some examples where the input is in the left column and the corresponding output is in the right column.

1,2,3 → 1,3,2

3,2,1 → 1,2,3

1,1,5 → 1,5,1

Parsing:

Dict is the number of occurrences of each word. Look for it in the while loop below. If the number of lookups for a word is greater than the number of occurrences of a word in words, the current loop will be terminated. The length of each word in words is the same, wordlen is the length of a single word, and totalLen is the length of all words in words. In the following for and while loops, it is equivalent to truncating a substring of length totalLen from the source string s, and then truncating a string of length wordLen from the substring and storing it in found each time, and terminating the while loop when a string in found is larger than a string in dict Otherwise, continue to search until the length of the search is greater than totalLen, then terminate the while loop, and then compare. If you still don't understand, you can also write this in the for loop, intercepting a string of length totalLen each time, and then intercepting a string of length wordLen with a string of length totalLen, which will most likely be compared with the string in words one by one.

What are the commonly used java frameworks? 1. Spring Web Web MVC is a Java-based lightweight Web framework that implements the request-driven type of Spring design pattern. 2. Shirojia Apache Shiro is a security framework for Java. 3. Mybatistion MyBatis is an excellent persistence layer framework that supports normal SQL queries, stored procedures and advanced mapping. 4. DubboPol Dubbo is a distributed service framework. 5. Mavenfine Maven is a project management and build automation tool. 6. RabbitMQ _ RabbitMQ is a highly concurrent and reliable AMQP message queuing server implemented with Erlang. 7. EhcacheJournal EhCache is a pure Java in-process caching framework.

The above is about "how to use java to solve the next ranking problem". If this article is helpful to you and think it is well written, please share it with your friends to learn new knowledge. if you want to know more about it, please pay more attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report