ได้รับแรงบันดาลใจจากคำถาม StackOverflow ที่ยังไม่เกิดขึ้น
ความคิดนั้นง่าย กำหนด String และอาร์เรย์ของ Strings ให้ลบอินสแตนซ์ของคำใด ๆ ในอาร์เรย์ (ไม่สนใจขนาดตัวพิมพ์) จากอินพุตสตริงอื่นที่ไม่ใช่แถวแรกพร้อมกับช่องว่างเพิ่มเติมที่อาจทำให้เกิด คำต้องตรงกับคำทั้งหมดในสตริงป้อนเข้าไม่ใช่ส่วนของคำ
เช่น"A cat called matt sat on a mat and wore a hat A cat called matt sat on a mat and wore a hat", ["cat", "mat"]
ควรส่งออก"A cat called matt sat on a mat and wore a hat A called matt sat on a and wore a hat"
อินพุต
- อินพุตสามารถใช้เป็นสตริงได้และอาร์เรย์ของ Strings หรืออาร์เรย์ของสตริงที่อินพุตสตริงเป็นองค์ประกอบแรก พารามิเตอร์เหล่านี้สามารถอยู่ในลำดับใดก็ได้
- สตริงอินพุตอาจไม่ถูกใช้เป็นรายการของสตริงที่คั่นด้วยช่องว่าง
- สตริงอินพุตจะไม่มีช่องว่างนำหน้าต่อท้ายหรือเว้นวรรคติดต่อกัน
- อินพุตทั้งหมดจะมีเฉพาะอักขระ [A-Za-z0-9] โดยมีข้อยกเว้นของสตริงอินพุตรวมถึงช่องว่างด้วย
- อาร์เรย์อินพุตอาจว่างเปล่าหรือมีคำที่ไม่อยู่ในสตริงป้อนเข้า
เอาท์พุต
- เอาต์พุตสามารถเป็นค่าส่งคืนจากฟังก์ชันหรือพิมพ์ไปที่ STDOUT
- เอาต์พุตจะต้องอยู่ในกรณีเดียวกันกับ String ดั้งเดิม
กรณีทดสอบ
the blue frog lived in a blue house, [blue] -> the blue frog lived in a house
he liked to read but was filled with dread wherever he would tread while he read, [read] -> he liked to read but was filled with dread wherever he would tread while he
this sentence has no matches, [ten, cheese] -> this sentence has no matches
this one will also stay intact, [] -> this one will also stay intact
All the faith he had had had had no effect on the outcome of his life, [had] -> All the faith he had no effect on the outcome of his life
5 times 5 is 25, [5, 6] -> 5 times is 25
Case for different case, [case] -> Case for different
the letters in the array are in a different case, [In] -> the letters in the array are a different case
This is a test Will this be correct Both will be removed, [this,will] -> This is a test Will be correct Both be removed
เช่นนี้เป็นรหัสกอล์ฟจำนวนไบต์ต่ำสุดชนะ!
This is a test Will this be correct Both will be removed
this will
คำสองคำที่สองถูกลบออกอย่างถูกต้อง แต่ยังลบคำbe
ที่สองหลังwill
ด้วยเหตุผลบางอย่าง