Wednesday, January 14, 2026
Latest:
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
  • How Spring framework resolves circular dependencies?
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Find the segmented input string into the words of a given dictionary.

Published: February 10, 2022Last updated: February 10, 2022
const findSegment = (dictionary, input) => {
    const result = []
    for(let i = 0; i < input.length; i++) {
        for(let j = i + 1; j <= input.length; j++) {
            const segment = input.slice(i, j);
            if(dictionary.indexOf(segment) > -1) {
                result.push(segment);
            }
        }
    }
    return result
};
const dictionary = ['apple', 'pear', 'pier', 'pie'];
const input = 'applepie';
console.log(findSegment(dictionary, input));

You May Also Like

Write a Program to Form Smallest Number From Two Digit Arrays

May 9, 2023 beroza

AWS IAM error : ‘Your authentication information is incorrect. Please try again’

October 25, 2019 beroza

How to load ads using Single Request Architecture in Google Publisher Tag?

June 30, 2021 beroza

How to render image with srcset and sizes in WordPress?

June 1, 2021 beroza

org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution

January 4, 2019 beroza

Largest Substring Between Two Equal Characters

December 29, 2022 beroza

CSS special selectors

August 26, 2021 beroza

rest_cannot_create Sorry, you are not allowed to create posts as this user in WordPress REST API

July 2, 2019 beroza

How to pass data from child component to parent in ReactJS?

August 15, 2021 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2026 Upokary. All rights reserved.